dapr / python-sdk

Dapr SDK for Python
Apache License 2.0
222 stars 125 forks source link

Add ruff auto fix #657

Closed litan1106 closed 7 months ago

litan1106 commented 8 months ago

Description

How to use it?

Issue reference

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

litan1106 commented 8 months ago

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

elena-kolevska commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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 commented 7 months ago

@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 :)

berndverst commented 7 months ago

@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 commented 7 months ago

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

codecov[bot] commented 7 months ago

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 :warning:
dapr/clients/grpc/client.py 84.00% 12 Missing :warning:
dapr/clients/http/dapr_actor_http_client.py 42.85% 12 Missing :warning:
ext/dapr-ext-fastapi/dapr/ext/fastapi/actor.py 50.00% 10 Missing :warning:
ext/flask_dapr/flask_dapr/actor.py 42.85% 8 Missing :warning:
dapr/clients/grpc/_request.py 45.45% 6 Missing :warning:
dapr/actor/runtime/state_manager.py 75.00% 5 Missing :warning:
dapr/conf/helpers.py 44.44% 5 Missing :warning:
...orkflow/dapr/ext/workflow/dapr_workflow_context.py 66.66% 5 Missing :warning:
...apr-ext-workflow/dapr/ext/workflow/retry_policy.py 37.50% 5 Missing :warning:
... and 20 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #657 +/- ## ======================================= Coverage 86.21% 86.21% ======================================= Files 79 79 Lines 3998 3998 ======================================= Hits 3447 3447 Misses 551 551 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.