-
Notifications
You must be signed in to change notification settings - Fork 4
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
Rewrite it in Rust: Ruff as alternative Linter #28
base: main
Are you sure you want to change the base?
Changes from all commits
ef0074b
d31db6f
e874e1b
f719968
fa474c9
b753ee1
25b6814
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,10 @@ channels: | |
- conda-forge | ||
dependencies: | ||
- black=23.1.0 | ||
- python=3.10.9 | ||
- cookiecutter=2.1.1 | ||
- pre-commit=3.0.4 | ||
- pylint=2.16.1 | ||
- pytest=7.2.1 | ||
- cookiecutter=2.1.1 | ||
- pytest=7.2.1 | ||
- python=3.10.9 | ||
- ruff=0.1.4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that we need ruff in the top-level environment, as we're only using one linter for the template repository itself. Let's stick with Pylint for now, so I guess you can revert all changes to that file. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really understand what this is good for. Can you explain? I guess it's somehow using one file or the other, but I don't understand how 🙈 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is related to a change in post_gen_project: data-science-project-template/hooks/post_gen_project.py Lines 110 to 116 in 25b6814
Basically, after the project is created, the type of linter is determined from manifest.yaml and the config for the other linter is deleted prior to committing. The procedure is taken from this cookiecutter issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the main confusion here is the name of the folder Instead of introducing yet another custom configuration file, we should move both configs (Pylint and Ruff) into that folder and adapt our |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
features: | ||
- name: pylint | ||
enabled: {{cookiecutter.linter_name == "pylint"}} | ||
resources: | ||
- .pylintrc | ||
- name: ruff | ||
enabled: {{cookiecutter.linter_name == "ruff"}} | ||
resources: | ||
- ruff.toml |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,14 @@ channels: | |
- conda-forge | ||
dependencies: | ||
- black=23.1.0 | ||
- nbqa=1.6.1 | ||
- python=3.10.9 | ||
- pre-commit=3.0.4 | ||
{%- if cookiecutter.install_jupyter == 'yes' %} | ||
- jupyter=1.0.0 | ||
- nbqa=1.6.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's a good idea to move "nbqa" into that conditional. However, if we do this, we also need to add a condition to the pre-commit config to avoid that the nbqa-tasks are executed when the dependency is not installed. |
||
{%- endif %} | ||
- python=3.10.9 | ||
- pre-commit=3.0.4 | ||
{%- if cookiecutter.linter_name == "pylint" %} | ||
- pylint=2.16.1 | ||
{%- elif cookiecutter.linter_name == "ruff" %} | ||
- ruff=0.1.4 | ||
{%- endif %} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed, let's do some testing with some existing projects to see if these settings are reasonable. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# sync with black | ||
line-length = 100 | ||
|
||
# No need for NBQA as ruff has native Jupyter support | ||
extend-include = ["*.ipynb"] | ||
|
||
# https://docs.astral.sh/ruff/rules/ | ||
ignore = [ | ||
# "E501", # Line too long, handled by black | ||
# "W291", # Trailing whitespace, handled by black | ||
# "W292", # Missing final newline, handled by black | ||
# "PLR0904", # Too many public methods | ||
# "PLR0911", # Too many return statements | ||
# "PLR0913", # Too many arguments | ||
# "PLC0415", # Import outside toplevel | ||
# NA as checks yet but mentioned in github comments | ||
# "C0305", # Trailing newlines, handled by black | ||
# "C0114", # Missing module docstring | ||
# "C0115", # Missing class docstring | ||
# "C0116", # Missing function docstring | ||
# "R0902", # Too many instance attributes | ||
# "R0903", # Too few public methods | ||
# "R0914", # Too many locals | ||
# "W0124", # Confusing with statement | ||
# "C0413", # Wrong import position | ||
# "C0410", # Multiple imports | ||
# "R1705", # No else return | ||
# "W0201", # Attribute defined outside init | ||
# "E1123", # Unexpected keyword arg | ||
# "C0401", # Wrong spelling in comment | ||
# "C0402", # Wrong spelling in docstring | ||
# "C0403" # Invalid character in docstring | ||
] |
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 guess you're excluding this, as we now use some templating in the file, correct?
To still make sure that the generated files pass our own quality standards, we should extend the tests with one variation that uses ruff.
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.
From my understanding, the check-toml pre-commit hook tries to parse the toml within the project directory as-is, which leads to a flag because it still contains template strings. This is not necessarily related to ruff/pylint, but to the way the check itself is executed. Let's discuss how to solve this :)
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.
Following up our discussion, I have implemented that the tests now execute the pre-commit hooks. On top of that, I've added the option to specify different configurations to run the tests in. With these changes in place, I'd suggest to: