Skip to content
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

Add ruff auto fix #657

Merged
merged 4 commits into from
Jan 19, 2024
Merged

Add ruff auto fix #657

merged 4 commits into from
Jan 19, 2024

Conversation

litan1106
Copy link
Contributor

Description

  • added a standardized way to lint and auto-format code. (like the golang fmt auto formatted)

How to use it?

  • execute tox -e ruff to auto-format code

Issue reference

  • we discussed it in discord python-sdk channel

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@litan1106 litan1106 requested review from a team as code owners January 10, 2024 22:26
Copy link
Member

@berndverst berndverst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR breaks the type check.

Locally, please run tox -e type, tox -e flake8, and tox -e py311

@litan1106
Copy link
Contributor Author

This PR breaks the type check.

Locally, please run tox -e type, tox -e flake8, and tox -e py311

All passed now. I just turned off the ruff auto format on these two lines.
image

@litan1106 litan1106 requested a review from berndverst January 13, 2024 15:11
@elena-kolevska
Copy link
Contributor

Thanks for the PR @litan1106. I had been thinking about adding a auto fixer for a while too.
One question - what's the reason for having both flake and ruff?

@litan1106
Copy link
Contributor Author

I think @berndverst wanted to keep flake8 for linting. Ruff can do both linting and auto format. I think it's okay to keep using flake8 since we don't want to change too many things in one PR.

@elena-kolevska
Copy link
Contributor

elena-kolevska commented Jan 15, 2024

I understand. Do they have different behaviour though? If we can configure ruff to use the same lint rules as flake8, keeping it simple with a single tool that does both things would be nice. One problem would be if we plan on using some of the flake plugins in the future... What do you think @berndverst?

Also, I think it would be best if we kept the PR to the configuration changes only. We can apply the new formatting in a separate PR later.

@berndverst
Copy link
Member

@elena-kolevska flake8 is a much much more common linter for Python. That's why I don't want to switch to ruff for linting :)

litan1106 and others added 2 commits January 18, 2024 14:08
Signed-off-by: Bernd Verst <[email protected]>
@berndverst
Copy link
Member

@litan1106 I force pushed to your PR - I split everything up into two commits.
1: Adding ruff configurations
2: Autoformatting everything using tox -e ruff
3: Adds a ruff check to CI

@berndverst
Copy link
Member

We can consider adding ruff as the linter in the future by the way. For now let us keep flake8 :)

Signed-off-by: Bernd Verst <[email protected]>
Copy link

codecov bot commented Jan 18, 2024

Codecov Report

Attention: 137 lines in your changes are missing coverage. Please review.

Comparison is base (593eb07) 86.21% compared to head (32aa1fe) 86.21%.

Files Patch % Lines
dapr/aio/clients/grpc/client.py 54.79% 33 Missing ⚠️
dapr/clients/grpc/client.py 84.00% 12 Missing ⚠️
dapr/clients/http/dapr_actor_http_client.py 42.85% 12 Missing ⚠️
ext/dapr-ext-fastapi/dapr/ext/fastapi/actor.py 50.00% 10 Missing ⚠️
ext/flask_dapr/flask_dapr/actor.py 42.85% 8 Missing ⚠️
dapr/clients/grpc/_request.py 45.45% 6 Missing ⚠️
dapr/actor/runtime/state_manager.py 75.00% 5 Missing ⚠️
dapr/conf/helpers.py 44.44% 5 Missing ⚠️
...orkflow/dapr/ext/workflow/dapr_workflow_context.py 66.66% 5 Missing ⚠️
...apr-ext-workflow/dapr/ext/workflow/retry_policy.py 37.50% 5 Missing ⚠️
... and 20 more
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #657   +/-   ##
=======================================
  Coverage   86.21%   86.21%           
=======================================
  Files          79       79           
  Lines        3998     3998           
=======================================
  Hits         3447     3447           
  Misses        551      551           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@berndverst berndverst merged commit 9660735 into dapr:main Jan 19, 2024
15 of 16 checks passed
@litan1106 litan1106 deleted the Add-ruff-auto-fix branch January 19, 2024 22:34
@berndverst berndverst added this to the v1.13 milestone Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants