-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Setting up Ruff and updating the repo content accordingly #594
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for this PR @ecoussoux-ansys, I left some minor comments
self = add_stdout_handler(self, level=level) | ||
|
||
def setLevel(self, level="DEBUG"): | ||
def setlevel(self, level="DEBUG"): |
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.
Same as before
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.
Thanks for spotting this and for the explanation.
I reverted in 7c944dc the others changes I had made to that method's name where you did not directly provide a suggested fix.
file_handler = logging.FileHandler(filename) | ||
file_handler.setLevel(level) | ||
file_handler.setlevel(level) |
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.
echo
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.
Thanks. Changes applied in 7c944dc for this and subsequent occurrences.
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.
Here is a new batch of suggestion :)
ruff.toml
Outdated
ignore = [ | ||
"D100", # Missing docstring in public module | ||
"D101", # Missing docstring in public class | ||
"D102", # Missing docstring in public method | ||
"D105", # Missing docstring in magic method | ||
"D400", # First line should end with a period | ||
"TD002", # Missing author in TODOs comment | ||
"TD003", # Missing issue link in TODOs comment | ||
] |
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.
@ecoussoux-ansys Can't those ignore be removed ? The repo doesn't contain too many content so it should be doable right ?
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.
Sure it's doable : Most of the issues reported by Ruff for which I initially decided to introduce these ignore rules were related to missing docstrings.
I added minimalist docstrings where possible and added a few "# noqa" flags to disable ruff checks for cases where I did not know better. I tried not to simply silence all reported errors by using such "# noqa" everywhere, hence the newly introduced docstrings, of admittedly limited usefulness.
Does this approach and my changes look good for you?
This PR implements the change discussed in #593, i.e. migrating the pyansys-dev-guide to Ruff.
The specific configs for Black, isort and flake8 are removed and the .pre-commit-config.yaml file is updated accordingly, while a ruff.toml file defining the rules used by Ruff for linting and formatting is introduced.
Python files fixed by Ruff are updated.
Since the project does not currently contain a pyproject.toml file, it was decided not to define one for the purpose of holding the Ruff configuration, but instead to specify it in a ruff.toml file placed at the root of the project. The introduction of a pyproject.toml file is considered to be beyond the scope of this PR, which is the motivation for this choice.
Should a pyproject.toml file be created in the future, the content of the ruff.toml can simply be added to it and this config file removed.
As indicated in #593, the use of blacken-docs in .pre-commit-config.yaml is maintained as this tool (used for formatting Python code blocks in documentation files) cannot currently be replaced by Ruff, which does not support formatting/linting of embedded code (particularly in .rst or .md files, see astral-sh/ruff#8237). Similarly, blacken-docs does not support the Ruff formatter as an alternative for Black (see adamchainz/blacken-docs#352).
This tool is therefore retained (see here about the Ruff pre-commit hook astral-sh/ruff-pre-commit#55) for this project, despite the remaining dependence on Black.
Close #593