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

CI: Add ruff #208

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 20 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,6 @@ repos:
- id: isort
name: isort (python)

# Python: Flake8 (checks only, does this support auto-fixes?)
#- repo: https://github.com/PyCQA/flake8
# rev: 4.0.1
# hooks:
# - id: flake8
# additional_dependencies: &flake8_dependencies
# - flake8-bugbear
# - pep8-naming
# exclude: ^(docs/.*|tools/.*)$
# Alternatively: use autopep8?

# Python Formatting
- repo: https://github.com/psf/black
rev: 23.9.1 # Keep in sync with blacken-docs
Expand All @@ -110,6 +99,26 @@ repos:
- black==23.9.1 # keep in sync with black hook
# TODO: black-jupyter

# Python: Ruff linter
# https://docs.astral.sh/ruff/
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, jupyter]

# Python: Flake8 (only for pyflake and bugbear)
# Ruff above is faster
#- repo: https://github.com/PyCQA/flake8
# rev: 6.1.0
# hooks:
# - id: flake8
# additional_dependencies: &flake8_dependencies
# - flake8-bugbear
# - Flake8-pyproject
# exclude: ^(docs/.*|tools/.*)$

# Jupyter Notebooks: clean up all cell outputs
- repo: https://github.com/roy-ht/pre-commit-jupyter
rev: v1.2.1
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
shutil.rmtree(dst_path)
shutil.copytree(src_path, dst_path)

for subdir, dirs, files in os.walk(dst_path):
for subdir, _dirs, files in os.walk(dst_path):
for f in files:
if f.find(".pyi") > 0:
dir_path = os.path.relpath(subdir, dst_path)
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@ requires = [
"cmake>=3.20.0,<4.0.0"
]
build-backend = "setuptools.build_meta"


[tool.flake8]
#ignore = ['E231', 'E241']
select = ['F', 'B']


[tool.ruff]
# https://docs.astral.sh/ruff/
select = ["E4", "E7", "E9", "F"]
ignore = ["E402"]
2 changes: 1 addition & 1 deletion tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
gm = geometry
bx = gm.Domain()

for non_periodic_coord in [0, 1]:
for _non_periodic_coord in [0, 1]:

Check failure

Code scanning / CodeQL

Suspicious unused loop iteration variable Error test

For loop variable '_non_periodic_coord' is not used in the loop body.
error_thrown = False
try:
gm.period(0)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_multifab.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_mfab_mfiter(make_mfab):
assert iter(mfab).length == 8

cnt = 0
for mfi in mfab:
for _mfi in mfab:
cnt += 1

assert iter(mfab).length == cnt
Expand Down
1 change: 1 addition & 0 deletions tests/test_particleContainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def test_per_cell(empty_particle_container, std_geometry, std_particle):

sum_1 = 0
for tile_ind, pt in lev.items():
print("tile", tile_ind)
real_arrays = pt.GetStructOfArrays().GetRealData()
sum_1 += np.sum(real_arrays[1])
print(sum_1)
Expand Down