-
Notifications
You must be signed in to change notification settings - Fork 113
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
Replace flake8
, isort
, pylint
and black
by ruff
#2149
Changes from 24 commits
c93246f
831b64f
38a1c0d
9de9801
d3f4bf7
51455a1
3523286
1f3dcfe
a7a5259
acda98f
89afdb3
80a9121
5812946
671ada4
51c05a9
13ba5a1
afaab24
aad3502
582e98e
4600f92
233cf2f
337cce6
57a3200
267c50f
31c693e
cbff524
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 |
---|---|---|
|
@@ -14,31 +14,11 @@ repos: | |
- id: check-json # Checks json files for parseable syntax. | ||
- id: check-case-conflict # Check for files that would conflict in case-insensitive filesystems | ||
- id: check-merge-conflict # Check for files that contain merge conflict strings. | ||
- id: debug-statements # Check for debugger imports and py37+ `breakpoint()` calls in python source. | ||
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.
|
||
- id: requirements-txt-fixer # Sorts entries in requirements.txt | ||
- id: flake8 | ||
args: | ||
- "--max-line-length=100" | ||
- "--max-complexity=18" | ||
- "--max-complexity=18" | ||
- "--select=B,C,E,F,W,T4,B9" | ||
- "--ignore=E203,E266,E501,W503" | ||
|
||
- repo: local | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.7.0 | ||
hooks: | ||
- id: isort | ||
name: "Sort imports" | ||
language: system | ||
types: [file, python] | ||
entry: isort | ||
- id: black | ||
name: "Black" | ||
language: system | ||
types: [file, python] | ||
entry: black | ||
- id: kedro lint | ||
name: "Kedro lint" | ||
language: python_venv | ||
types: [file, python] | ||
entry: kedro lint | ||
stages: [commit] | ||
- id: ruff | ||
args: [--fix] | ||
- id: ruff-format |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extend = "../ruff.toml" | ||
|
||
[lint.isort] | ||
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. Is this a best practice to have ruff.toml ? Can we do this in demo-project/pyproject.toml -> table [tool.ruff.lint.isort] ? 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.
There is no explicit recommendation in
So I use Let me know if you disagree & still prefer the 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 came up with a better argument :)
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. Sure, I am happy to have ruff.toml, I wanted to understand if this was a better practice suggested from ruff. Thanks for the PR |
||
known-first-party = ["demo_project"] | ||
known-third-party = ["kedro"] |
This file was deleted.
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. Diffs like this, or e.g. adding a blank line between module docstring and first import line, is what |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
"""demo-project | ||
""" | ||
"""demo-project""" | ||
|
||
__version__ = "0.1" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Project hooks.""" | ||
|
||
import logging | ||
import time | ||
from typing import Any | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,21 +27,21 @@ def create_pipeline(**kwargs) -> Pipeline: | |
func=apply_types_to_companies, | ||
inputs="companies", | ||
outputs="int_typed_companies", | ||
name='apply_types_to_companies', | ||
tags='companies' | ||
name="apply_types_to_companies", | ||
tags="companies", | ||
), | ||
node( | ||
func=apply_types_to_shuttles, | ||
inputs="shuttles", | ||
outputs="int_typed_shuttles@pandas1", | ||
name='apply_types_to_shuttles', | ||
tags='shuttles' | ||
name="apply_types_to_shuttles", | ||
tags="shuttles", | ||
Comment on lines
-37
to
+38
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. Another autofix from 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. The formatter was run only on |
||
), | ||
node( | ||
func=apply_types_to_reviews, | ||
inputs=["reviews", "params:typing.reviews.columns_as_floats"], | ||
outputs="int_typed_reviews", | ||
name='apply_types_to_reviews' | ||
name="apply_types_to_reviews", | ||
), | ||
node( | ||
func=aggregate_company_data, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,10 @@ | |
from demo_project.pipelines.reporting.nodes import ( | ||
create_feature_importance_plot, | ||
create_matplotlib_chart, | ||
get_top_shuttles_data, | ||
make_cancel_policy_bar_chart, | ||
make_price_analysis_image, | ||
make_price_histogram, | ||
get_top_shuttles_data, | ||
Comment on lines
+11
to
-14
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'm curious why |
||
) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
To run the tests, run ``kedro test``. | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
This file was deleted.
This file was deleted.
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.
Note how this simplifies after we define all settings, including directories and rulesets, once, in a central
ruff.toml
configuration file. This allows all "parties" that useruff
:To run just
ruff check
andruff format
from anywhere in the repo, and it applies a corresponding configuration automatically.