-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Enable RUF013 to enforce optional typing #37266
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
Conversation
|
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the |
fec79ae to
7320dcf
Compare
|
LGTM! One issue, though: We generally don't enforce type hinting. I understand that this will only enforce |
|
@Rocketknight1 And only when we write incomplete types that can default to None. If we don't write types for new code, the check doesn't force us to type them. |
da774d9 to
4f27575
Compare
Signed-off-by: cyy <[email protected]>
|
@ArthurZucker This is useful for accurate typing. |
|
@cyyever can you check the failing files in |
Signed-off-by: cyy <[email protected]>
|
@Rocketknight1 Because of other packages, ruff was downgraded to 0.9 on my host.. |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
No probs @cyyever, it looks good now! cc @ArthurZucker @Cyrilvallez - let me know if you're okay with adding an extra Ruff rule here to enforce |
ArthurZucker
left a comment
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.
Sure! Thanks for the contrib
* Enable RUF013 for Optional typing Signed-off-by: cyy <[email protected]> * Add Optional to types * Format code Signed-off-by: cyy <[email protected]> --------- Signed-off-by: cyy <[email protected]>
What does this PR do?
This PR adds Optional to remaining types and add
RUF013rule to enforce that.RUFF rule
RUF013checks for the use of implicit Optional in type annotations when the default parameter value is None.