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

chore(ruff): Enable ignored UP rules #3741

Closed
wants to merge 2 commits into from
Closed

chore(ruff): Enable ignored UP rules #3741

wants to merge 2 commits into from

Conversation

bellini666
Copy link
Member

@bellini666 bellini666 commented Dec 25, 2024

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 of Union[X, Y] and X | None instead of Optional[X], but I'm not sure if there would be any unwanted consequences in doing this?

Summary by Sourcery

Chores:

  • Replace Union[X, Y] with X | Y and Optional[X] with X | None.

@bellini666 bellini666 self-assigned this Dec 25, 2024
Copy link
Contributor

sourcery-ai bot commented Dec 25, 2024

Reviewer's Guide by Sourcery

This pull request refactors the codebase to use the pipe operator | instead of Union and Optional for type hinting.

Class diagram showing type hint changes

classDiagram
    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"
Loading

File-Level Changes

Change Details Files
Replaced Union and Optional type hints with the pipe operator.
  • Used the pipe operator `
for optional types instead ofOptional[X].</li><li>Used the pipe operator

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
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,
Copy link
Contributor

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:

@@ -114,10 +114,10 @@ async def _handle_response(self, response: Any) -> Response:
async def _graphql_request(
self,
method: Literal["get", "post"],
Copy link
Contributor

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:

@@ -74,10 +74,10 @@ def __init__(
async def _graphql_request(
self,
method: Literal["get", "post"],
Copy link
Contributor

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:

@botberry
Copy link
Member

Apollo Federation Subgraph Compatibility Results

Federation 1 Support Federation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🔲
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

Learn more:

@botberry
Copy link
Member

Hi, thanks for contributing to Strawberry 🍓!

We noticed that this PR is missing a RELEASE.md file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI!

So as soon as this PR is merged, a release will be made 🚀.

Here's an example of RELEASE.md:

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:

🆕 Release (next) is out! Thanks to @_bellini666 for the PR 👏

Get it here 👉 https://strawberry.rocks/release/(next)

1 similar comment
@botberry
Copy link
Member

Hi, thanks for contributing to Strawberry 🍓!

We noticed that this PR is missing a RELEASE.md file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI!

So as soon as this PR is merged, a release will be made 🚀.

Here's an example of RELEASE.md:

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:

🆕 Release (next) is out! Thanks to @_bellini666 for the PR 👏

Get it here 👉 https://strawberry.rocks/release/(next)

@bellini666
Copy link
Member Author

Apparently we can enable this next year, after we drop support for 3.9 =P

@bellini666 bellini666 closed this Dec 25, 2024
@bellini666 bellini666 deleted the ruff_up_rule branch December 25, 2024 15:15
Copy link

codspeed-hq bot commented Dec 25, 2024

CodSpeed Performance Report

Merging #3741 will not alter performance

Comparing ruff_up_rule (1f2ad37) with main (e78f8c6)

Summary

✅ 21 untouched benchmarks

Copy link

codecov bot commented Dec 25, 2024

Codecov Report

Attention: Patch coverage is 96.56250% with 11 lines in your changes missing coverage. Please review.

Project coverage is 72.29%. Comparing base (e78f8c6) to head (1f2ad37).

❗ There is a different number of reports uploaded between BASE (e78f8c6) and HEAD (1f2ad37). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (e78f8c6) HEAD (1f2ad37)
2 1
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     

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.

2 participants