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

Enable RUF013 to enforce optional typing #37266

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cyyever
Copy link
Contributor

@cyyever cyyever commented Apr 4, 2025

What does this PR do?

This PR adds Optional to remaining types and add RUF013 rule to enforce that.

RUFF rule RUF013 checks for the use of implicit Optional in type annotations when the default parameter value is None.

@cyyever cyyever changed the title Enable RUF013 for Optional typying Enable RUF013 for Optional typing Apr 4, 2025
@github-actions github-actions bot marked this pull request as draft April 4, 2025 02:33
Copy link

github-actions bot commented Apr 4, 2025

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 Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@cyyever cyyever changed the title Enable RUF013 for Optional typing Enable RUF013 to enforce optional typing Apr 4, 2025
@cyyever cyyever marked this pull request as ready for review April 4, 2025 02:34
@github-actions github-actions bot requested review from ArthurZucker and qubvel April 4, 2025 02:34
Signed-off-by: cyy <cyyever@outlook.com>
@Rocketknight1 Rocketknight1 removed the request for review from qubvel April 4, 2025 12:11
@Rocketknight1
Copy link
Member

LGTM! One issue, though: We generally don't enforce type hinting. I understand that this will only enforce Optional where there is already a type hint and the default value is None, which makes a lot of sense, but I still want to check with the core maintainers @ArthurZucker and @Cyrilvallez that they're okay with a type hint style check like this!

@cyyever
Copy link
Contributor Author

cyyever commented Apr 4, 2025

@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.

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