-
-
Notifications
You must be signed in to change notification settings - Fork 541
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
chore(ruff): Enable ignored UP rules #3741
Conversation
Reviewer's Guide by SourceryThis pull request refactors the codebase to use the pipe operator Class diagram showing type hint changesclassDiagram
class TypeHints {
Before
+Optional[str]
+Union[X, Y]
+Optional[list[type[BasePermission]]]
+Union[Callable[..., object], object]
After
+str | None
+X | Y
+list[type[BasePermission]] | None
+Callable[..., object] | object
}
note for TypeHints "Changes in type hint syntax
Moving from Union/Optional to | operator"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
for more information, see https://pre-commit.ci
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.
Hey @bellini666 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -70,7 +69,7 @@ def to_tuple(self) -> tuple[str, type, dataclasses.Field]: | |||
def get_default_factory_for_field( | |||
field: CompatModelField, |
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.
issue (code-quality): We've found these issues:
- Hoist a repeated condition into a parent condition (
hoist-repeated-if-condition
) - Swap positions of nested conditionals (
swap-nested-ifs
) - Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Hoist nested repeated code outside conditional statements (
hoist-similar-statement-from-if
)
tests/http/clients/fastapi.py
Outdated
@@ -114,10 +114,10 @@ async def _handle_response(self, response: Any) -> Response: | |||
async def _graphql_request( | |||
self, | |||
method: Literal["get", "post"], |
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.
issue (code-quality): We've found these issues:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif
)
tests/http/clients/sanic.py
Outdated
@@ -74,10 +74,10 @@ def __init__( | |||
async def _graphql_request( | |||
self, | |||
method: Literal["get", "post"], |
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.
issue (code-quality): We've found these issues:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif
)
Apollo Federation Subgraph Compatibility Results
Learn more: |
Hi, thanks for contributing to Strawberry 🍓! We noticed that this PR is missing a So as soon as this PR is merged, a release will be made 🚀. Here's an example of Release type: patch
Description of the changes, ideally with some examples, if adding a new feature. Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :) Here's the tweet text:
|
1 similar comment
Hi, thanks for contributing to Strawberry 🍓! We noticed that this PR is missing a So as soon as this PR is merged, a release will be made 🚀. Here's an example of Release type: patch
Description of the changes, ideally with some examples, if adding a new feature. Release type can be one of patch, minor or major. We use semver, so make sure to pick the appropriate type. If in doubt feel free to ask :) Here's the tweet text:
|
Apparently we can enable this next year, after we drop support for 3.9 =P |
CodSpeed Performance ReportMerging #3741 will not alter performanceComparing Summary
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3741 +/- ##
===========================================
- Coverage 97.27% 72.29% -24.99%
===========================================
Files 501 496 -5
Lines 33408 32245 -1163
Branches 5480 1663 -3817
===========================================
- Hits 32499 23310 -9189
- Misses 701 8665 +7964
- Partials 208 270 +62 |
Was testing enabling some ruff rules and this one was able to fix itself completly with
check --fix
Personally I do prefer
X | Y
instead ofUnion[X, Y]
andX | None
instead ofOptional[X]
, but I'm not sure if there would be any unwanted consequences in doing this?Summary by Sourcery
Chores:
Union[X, Y]
withX | Y
andOptional[X]
withX | None
.