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

Adopt more ruff rules to align with AWB codebase #785

Merged
merged 9 commits into from
Jul 31, 2024

Conversation

danielhollas
Copy link
Contributor

@danielhollas danielhollas commented Jul 24, 2024

I've copied over the ruff configuration from AWB which served us well so far. Most of the necessary fixes were done automatically, I've done around 20 of them manually.

TODO: fix violations in notebooks and use ruff to lint notebooks directly.

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

Attention: Patch coverage is 67.39130% with 30 lines in your changes missing coverage. Please review.

Project coverage is 68.22%. Comparing base (02ee3ab) to head (3e49388).
Report is 43 commits behind head on main.

Files with missing lines Patch % Lines
src/aiidalab_qe/plugins/xas/result.py 9.09% 10 Missing ⚠️
src/aiidalab_qe/common/widgets.py 50.00% 6 Missing ⚠️
src/aiidalab_qe/__main__.py 40.00% 3 Missing ⚠️
src/aiidalab_qe/common/bandpdoswidget.py 62.50% 3 Missing ⚠️
src/aiidalab_qe/common/node_view.py 40.00% 3 Missing ⚠️
src/aiidalab_qe/app/result/workchain_viewer.py 90.00% 1 Missing ⚠️
src/aiidalab_qe/app/utils/search_jobs.py 0.00% 1 Missing ⚠️
src/aiidalab_qe/common/process.py 50.00% 1 Missing ⚠️
src/aiidalab_qe/common/setup_codes.py 66.66% 1 Missing ⚠️
src/aiidalab_qe/plugins/xps/result.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #785   +/-   ##
=======================================
  Coverage   68.21%   68.22%           
=======================================
  Files          45       45           
  Lines        4147     4148    +1     
=======================================
+ Hits         2829     2830    +1     
  Misses       1318     1318           
Flag Coverage Δ
python-3.10 68.22% <67.39%> (+<0.01%) ⬆️
python-3.9 68.25% <67.39%> (+<0.01%) ⬆️

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.

target-version = "py39"

[tool.ruff.lint]
ignore = ["E501", "E402", "TRY003", "RUF012", "N806"]

Choose a reason for hiding this comment

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

Should we add docstring about this one to keep in mind when to use them ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure what you mean by this comment? These are rules that we do not enforce, for various reasons, mostly because they would be too tedious to enforce. You can learn by each of them by running

ruff rule <rule_code>

@danielhollas danielhollas force-pushed the more-ruff branch 3 times, most recently from cc6f17c to d0d22a9 Compare July 29, 2024 12:54
Fixed 30 errors:
- src/aiidalab_qe/app/configuration/pseudos.py:
    1 × C408 (unnecessary-collection-call)
- src/aiidalab_qe/common/bandpdoswidget.py:
    8 × C408 (unnecessary-collection-call)
    1 × UP031 (printf-string-formatting)
    1 × UP032 (f-string)
- src/aiidalab_qe/common/node_view.py:
    1 × C408 (unnecessary-collection-call)
- src/aiidalab_qe/common/process.py:
    1 × C408 (unnecessary-collection-call)
- src/aiidalab_qe/common/widgets.py:
    4 × RUF005 (collection-literal-concatenation)
    3 × C408 (unnecessary-collection-call)
- src/aiidalab_qe/plugins/bands/workchain.py:
    1 × B007 (unused-loop-control-variable)
- src/aiidalab_qe/plugins/pdos/workchain.py:
    1 × C405 (unnecessary-literal-set)
- src/aiidalab_qe/plugins/xas/setting.py:
    1 × C416 (unnecessary-comprehension)
- src/aiidalab_qe/plugins/xps/result.py:
    1 × C408 (unnecessary-collection-call)
- src/aiidalab_qe/plugins/xps/workchain.py:
    2 × RUF015 (unnecessary-iterable-allocation-for-first-element)
- tests/test_plugins_electronic_structure.py:
    1 × RUF015 (unnecessary-iterable-allocation-for-first-element)
- tests/test_pseudo.py:
    3 × C416 (unnecessary-comprehension)
@danielhollas
Copy link
Contributor Author

@AndresOrtegaGuerrero thank you for the review, please see my replies.

I've changed the configuration so that ruff now checks notebooks directly as well, and removed the nbqa pre-commit hook which is now not needed.

Copy link
Member

@AndresOrtegaGuerrero AndresOrtegaGuerrero left a comment

Choose a reason for hiding this comment

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

Thank you for your work @danielhollas LGTM! , I was wondering if @superstar54 or @PNOGillespie can check the XPS part in particular the test where there are lines not used.

Copy link
Member

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

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

Thanks for the work. LGTM!

@danielhollas danielhollas merged commit 94b92f3 into aiidalab:main Jul 31, 2024
8 checks passed
@danielhollas danielhollas deleted the more-ruff branch July 31, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants