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

Improve validator typing to allow non-number formats for min and max #516

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

cdce8p
Copy link
Contributor

@cdce8p cdce8p commented Jun 25, 2024

NullableNumber is defined as int | float | None. This prevents the use of other values for min / max in Range, Clamp and Length which also support rich comparisons. E.g. timedelta.

Use SupportsAllComparisons from _typeshed instead.

Refs home-assistant/core#120268
/CC @bdraco

Copy link
Contributor

@bdraco bdraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix

@alecthomas alecthomas merged commit 65f736c into alecthomas:master Jun 25, 2024
8 checks passed
@cdce8p cdce8p deleted the improve-validator-typing branch June 25, 2024 20:55
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.

3 participants