Skip to content

Conversation

@JDBetteridge
Copy link
Contributor

@JDBetteridge JDBetteridge commented Oct 16, 2025

I'm trying to automate detection a lot of the "nitpick" code review comments and providing a route to automatically fixing the issues apriori.

What I have added to CI is equivalent to locally running:

isort --check-only --sort-reexports --multi-line VERTICAL_GRID_GROUPED --line-length 90 --force-alphabetical-sort-within-sections --project devito,examples .
ruff check --preview  --select E,W,F,B,UP,SIM,I,RUF022 --ignore F403,E226,E731,E275,F405,E722,E741,W605 --line-length=90 --output-format concise

Most command line arguments are included in the pyproject.toml and checking out this branch you can just run

isort --check-only .
ruff check --output-format concise

Fixing most linting issues is as simple as

isort .
ruff check --fix

if you trust the auto-formatter!

This PR also extends linting to Dockerfiles and Github actions too.

An excerpt from CONTRIBUTING.md:

Coding guidelines

Some coding rules are "enforced" (and automatically checked by our Continuous Integration systems), some are "strongly recommended", others are "optional" but welcome.

  • We enforce PEP8, with a few exceptions, listed here
  • We enforce a maximum line length of 90 characters.
  • We enforce indentation via 4 spaces.
  • We suggest to use flake8 to check the above points locally, before filing a Pull Request.
  • We strongly recommend to document any new module, class, routine, ... with NumPy-like docstrings ("numpydoc").
  • We strongly recommend imports to be at the top of a module, logically grouped and, within each group, to be alphabetically ordered. As an example, condider our init.py: the first group is imports from the standard library; then imports from third-party dependencies; finally, imports from devito modules.
  • We strongly recommend to follow standard Python coding guidelines:
    • Use camel caps for class names, e.g. class FooBar.
    • Method names must start with a small letter; use underscores to separate words, e.g. def _my_meth_....
    • Private class attributes and methods must start with an underscore.
    • Variable names should be explicative (Devito prefers "long and clear" over "short but unclear").
    • Comment your code, and do not be afraid of being verbose. The first letter must be capitalized. Do not use punctuation (unless the comment consists of multiple sentences).
  • We like that blank lines are used to logically split blocks of code implementing different (possibly sequential) tasks.

@JDBetteridge JDBetteridge requested a review from EdCaunt October 16, 2025 23:17
@JDBetteridge JDBetteridge added CI continuous integration misc python Pull requests that update python code github_actions Pull requests that update GitHub Actions code labels Oct 16, 2025
@codecov
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

❌ Patch coverage is 82.08517% with 244 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.19%. Comparing base (59c357b) to head (c8bb54c).

Files with missing lines Patch % Lines
devito/mpi/routines.py 18.60% 35 Missing ⚠️
tests/test_data.py 56.75% 16 Missing ⚠️
devito/mpi/distributed.py 37.50% 15 Missing ⚠️
devito/arch/compiler.py 50.00% 12 Missing and 2 partials ⚠️
tests/test_ir.py 48.14% 14 Missing ⚠️
tests/test_operator.py 41.66% 14 Missing ⚠️
benchmarks/user/benchmark.py 54.16% 11 Missing ⚠️
devito/data/data.py 38.46% 8 Missing ⚠️
devito/tools/data_structures.py 50.00% 8 Missing ⚠️
devito/data/utils.py 53.84% 5 Missing and 1 partial ⚠️
... and 58 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2771      +/-   ##
==========================================
+ Coverage   83.02%   83.19%   +0.16%     
==========================================
  Files         248      248              
  Lines       50804    50589     -215     
  Branches     4479     4392      -87     
==========================================
- Hits        42180    42087      -93     
+ Misses       7857     7753     -104     
+ Partials      767      749      -18     
Flag Coverage Δ
pytest-gpu-aomp-amdgpuX 68.79% <71.39%> (+0.25%) ⬆️
pytest-gpu-nvc-nvidiaX 69.31% <71.41%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# But ignore these inconvenient rules
ignore = ["F403", "E226", "E731", "E275", "F405", "E722", "E741", "W605"]

[tool.isort]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you look back 10 years ago or so there's a commit with message "FREEEEEEEEEEEEEDOOOMM" in which we are essentially removing isort from devito 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the motivation for removing?

[tool.isort]
line_length = 90
known_first_party = ["devito", "examples"]
multi_line_output = "VERTICAL_GRID_GROUPED"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is for

from X import (
A,
B,
C,
...
)

then I vote no

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this is in direct response to your comment on my other PR. This is specifically to avoid using ruff for the import formatting (see this issue)

@JDBetteridge JDBetteridge self-assigned this Nov 7, 2025
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI continuous integration github_actions Pull requests that update GitHub Actions code misc python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants