-
Notifications
You must be signed in to change notification settings - Fork 82
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
Ruff code auto-format #1105
Ruff code auto-format #1105
Conversation
Flake8 fails, but it's fine by now. It's only a first iteration of introducing 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.
Since this is python and even format changes can easily break functionality can you describe what short of testing did you perform to validate the PR?
@@ -33,9 +33,9 @@ install-cdkproxy: | |||
install-tests: | |||
pip install -r tests/requirements.txt | |||
|
|||
lint: |
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 wouldn't makefile target tool specific, let's keep it as lint
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.
May be we can keep both? I don't want the name to be confusing, since it's just an alias
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.
Previously we were running flake8
and we called the target lint
and not flake8
which I think is correct because it's abstracting whatever underlying linter we use and also that way we wouldn't have to change the pipelines code.
python -m flake8 --exclude cdk.out,blueprints --ignore E402,E501,F841,W503,F405,F403,F401,E712,E203 backend/ | ||
ruff: | ||
pip install ruff | ||
ruff check --fix |
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.
shouldn't we run ruff format
here as well?
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.
btw forgot to say that we should be taking into account both check and format exit codes and fail the target if either of them fail.
line-length = 120 | ||
target-version = ["py37", "py38", "py39", "py310"] |
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.
Should we keep target-version
as 39 which is the lambda runtime version we use?
pyproject.toml
Outdated
|
||
[tool.ruff.lint] | ||
exclude = [ "backend/migrations","tests/**", "**/input_types.py", "**/mutations.py", "**/queries.py", "**/types.py", "**/api/__init__.py"] |
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.
why exclude migrations?
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.
Alembic has one weakness, you sometimes have to keep unused imports and other strange stuff. Also, migrations are usually something very specifically tailored, so I thought it's better to exclude this.
But of course I can just add 'noqa'-statements, where it's needed
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.
If there are standard strange stuff for Alembic perhaps it's better to use per-file-ignores than noqa
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 enabled all formatting back. And added block-comment for current unused imports. In future, if something like this comes up again, we can decide on-the-go, if any other re-configuration is needed
And the problem with flake8 testing of this PR is |
|
Oh I thought we were going to drop flake8 on a next PR. |
I think another thing you could run is to make some requests through the cdkproxy, an action that will create a new stack (i.e create a new dataset or environment etc) |
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.
Looks good to me
Feature or Bugfix
Detail
Ruff tool configured for the project.
All files are formatted
In pipelines instead of "make lint" now "make ruff" is used
Relates
#1076
Security
Please answer the questions below briefly where applicable, or write
N/A
. Based onOWASP 10.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.