Uh oh!
There was an error while loading. Please reload this page.
Use Literal for statistics.quantiles() - #7463
Conversation
This comment has been minimized.
This comment has been minimized.
JelleZijlstra
left a comment
There was a problem hiding this comment.
Looks good. I don't think #7258 needs to block this.
Diff from mypy_primer, showing the effect of this PR on open source code: core (https://github.com/home-assistant/core)
+ homeassistant/components/statistics/sensor.py:646: error: Argument "method" to "quantiles" has incompatible type "str"; expected "Union[Literal['inclusive'], Literal['exclusive']]" [arg-type] |
Given that there are false positives in practice, "prefer false negatives over false positives" would imply we shouldn't do this without a fallback overload right? |
AlexWaygood
commented
Mar 8, 2022
How would we do a fallback overload in this case? |
AlexWaygood
left a comment
There was a problem hiding this comment.
I think this is a good change to make. The one false positive is very easily fixed. #7258 is a temporary moratorium on literal constants, not on literal argument types.
hauntsaninja
commented
Mar 8, 2022
It'd be a bad fallback in that we'd have zero additional type safety but would still mean we get better IDE hover docs / completion docs :-) |
AlexWaygood
commented
Mar 8, 2022
Shoot, I screwed up the commit description a bit there. Apologies :) |
Akuli
commented
Mar 8, 2022
It happens :) It's not super critical with stdlib stubs anyway. With third-party stubs, this matters more because commit messages turn into an auto-generated changelog. |
Fixes#7462