-
Notifications
You must be signed in to change notification settings - Fork 4
tests: add linter and check black #1
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
Draft
utnapischtim
wants to merge
1
commit into
inveniosoftware:master
Choose a base branch
from
utnapischtim:linter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with this is that you cannot run this locally, before pushing your changes.
That's why we have the
run-tests.shand the rules configured in thesetup.cfg.What are actually checking now with
ruff?Wasn't it
black+isortenough?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we have the
run-tests.shbut if we change something there, we have to apply it again on every package.introducing this change, would improve the test workflow on github without interfering locally. in my thinking the local development checks about black in the IDE by applying black on the save file hook. further isort is applied there too. so if you run
run-tests.shlocally with black and isort included it should not be a problem if it runs at the end of the pytest tests.the same configuration, as we have locally would still work on github, but would not fail anymore since it would fail before, so we are faster.
i enabled following ruff rules:
T20 .. p(p)rint statements
F401 .. unused imports
F841 .. unused variable
F811 .. redefined while unused
which are not covered by black and isort. the
Istands for isort. i included that, because ruff has it included, but we can remove that and stay on isort for it. for me i would like to include those linter rules, because some of them can hide bugsunused variableandredefined while unused.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not against this, but we need to be aware that it will initially fail for some repositories. I randomly ran it on Invenio-Communities
ruff check --select I,T20,F401,F841,F811 ... Found 18 errors. No fixes available (18 hidden fixes can be enabled with the `--unsafe-fixes` option).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it will fail. if it would not fail, i would have not the reason to activate it!
i included only the bar minimum what i think we should enable. we can discuss afterwards if we want to introduce further rules. on my packages i do it the other way around, i enable all rules and ignore rules where i think they are to much or are not applicable to the invenio code base