Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add style testing #300

Merged
merged 30 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bb64f19
add style testing
jcapriot Jan 23, 2023
36b8374
update call
jcapriot Jan 23, 2023
1ce386d
add target for black
jcapriot Jan 23, 2023
4502328
only look in discretize for doctests
jcapriot Jan 23, 2023
e3e4c3e
update flake8 ignores
jcapriot Jan 24, 2023
4ce8d25
update for flake8 formating on examples and tutorials
jcapriot Jan 24, 2023
ddf5490
fix style in tests/
jcapriot Jan 24, 2023
bf3bac1
fix style for discretize package
jcapriot Jan 24, 2023
d205390
add rfloordiv tests for Identity()
jcapriot Jan 24, 2023
155ef4f
Update docstrings in utils for style
jcapriot Jan 24, 2023
40ecaaa
operator style updates
jcapriot Jan 25, 2023
3ab79e4
doc style updates for mixins
jcapriot Jan 25, 2023
6ff1b02
base style updates
jcapriot Jan 25, 2023
8e4f7ef
unstructured style fixes
jcapriot Jan 25, 2023
510a6f3
tree mesh style fixes
jcapriot Jan 25, 2023
3d2f993
Update TensorMesh and test style
jcapriot Jan 25, 2023
200a2e4
update cylindrical mesh
jcapriot Jan 26, 2023
ca694bc
Update curvilinear mesh style
jcapriot Jan 26, 2023
946fff1
update flake8 config and minimum flake8-docstring version
jcapriot Jan 26, 2023
e2f504a
update style for _TreeMesh and TreeCell, even though .pyx files can't…
jcapriot Jan 26, 2023
67439fc
last style updates
jcapriot Jan 26, 2023
4ddb922
fix omf test
jcapriot Jan 26, 2023
ce71edf
Fix FutureWarning
jcapriot Jan 26, 2023
5e25b8c
Change title
jcapriot Jan 26, 2023
671a666
Fix typo in Identity rfloordiv
jcapriot Jan 26, 2023
5dd133d
Merge branch 'main' into style_checking
jcapriot Jan 26, 2023
5d5de8c
do a check with black
jcapriot Jan 26, 2023
dc6a450
update black run
jcapriot Jan 26, 2023
d0ab9ab
add inline math
jcapriot Jan 27, 2023
a2fd228
Fix newline rst math errors.
jcapriot Jan 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# -----------------------------
# Configuration file for flake8
# -----------------------------

# Configure flake8
# ----------------
[flake8]
extend-ignore =
# Too many leading '#' for block comment
E266,
# Line too long (82 > 79 characters)
E501,
# Do not use variables named 'I', 'O', or 'l'
E741,
# Line break before binary operator (conflicts with black)
W503,
# Ignore spaces before a colon (Black handles it)
E203,
# Ignore spaces around an operator (Black handles it)
E225,
# Ignore rst warnings for start and end, due to *args and **kwargs being invalid rst, but good for numpydoc
RST210,RST213,
exclude =
.git,
.eggs,
version.py,
setup.py,
__pycache__,
.ipynb_checkpoints,
docs/examples/*,
docs/tutorials/*,
docs/*,
discretize/_extensions/*.py
per-file-ignores =
# disable unused-imports errors on __init__.py
# Automodule used for __init__ scripts' description
__init__.py: F401, D204, D205, D400,
# do not check for assigned lambdas in tests
# do not check for missing docstrings in tests
tests/*: E731, D,
tutorials/*: D,
examples/*: D,

exclude-from-doctest =
# Only check discretize for docstring style
tests/*,
tutorials/*,

# Configure flake8-rst-docstrings
# -------------------------------
docstring-convention=numpy
# Add some roles used in our docstrings
rst-roles =
class,
func,
mod,
meth,
ref,
data,
# Python programming language:
py:func,py:mod,py:attr,py:meth,
# Collapse functionality
rst-directives =
# These are sorted alphabetically - but that does not matter
autosummary,currentmodule,deprecated,collapse,
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 23.1a1
hooks:
- id: black
language_version: python3.10
30 changes: 30 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@ pr:
- '*no-ci*'

stages:

- stage: StyleChecks
displayName: "Style Checks"
jobs:
- job:
displayName: Run style checks with Black
pool:
vmImage: ubuntu-latest
variables:
python.version: '3.8'
steps:
- script: |
pip install -r requirements_style.txt
displayName: "Install dependencies to run the checks"
- script: black --check .
displayName: "Run black"

- job:
displayName: Run style checks with flake8
pool:
vmImage: ubuntu-latest
variables:
python.version: '3.8'
steps:
- script: |
pip install -r requirements_style.txt
displayName: "Install dependencies to run the checks"
- script: flake8
displayName: "Run flake8"

- stage: Testing
jobs:
- template: ./.azure-pipelines/azure-pipelines-linux.yml
Expand Down
2 changes: 1 addition & 1 deletion discretize/Tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from discretize.tests import *
from discretize.tests import * # NOQA F401,F403
from discretize.utils.code_utils import deprecate_module

# note this needs to be a module with an __init__ so we can avoid name clash
Expand Down
3 changes: 2 additions & 1 deletion discretize/View.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Deprecated view module."""
from discretize.utils.code_utils import deprecate_module

deprecate_module(
Expand All @@ -7,6 +8,6 @@
future_warn=True,
)
try:
from discretize.mixins.mpl_mod import Slicer
from discretize.mixins.mpl_mod import Slicer # NOQA F401
except ImportError:
pass
Loading