| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
for more information, see https://pre-commit.ci
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Sorry, something went wrong.
|
Merging, but comments are very welcome! |
Sorry, something went wrong.
|
This change seems to have introduced a small regression. from enum import StrEnum
class Capability(StrEnum):
COLOR_CONTROL = "colorControl"
COLOR_TEMPERATURE = "colorTemperature"
def func(capability: Capability | str):
if capability in (Capability.COLOR_CONTROL, Capability.COLOR_TEMPERATURE):
reveal_type(capability)# before
Capability
# now
Capability | strIt reverses part of the improvement from #20602. |
Sorry, something went wrong.
|
Thanks for the post, but this is actually an improvement! from enum import StrEnum
class Capability(StrEnum):
COLOR_CONTROL = "colorControl"
COLOR_TEMPERATURE = "colorTemperature"
def func(capability: Capability | str):
if capability in (Capability.COLOR_CONTROL, Capability.COLOR_TEMPERATURE):
print(capability, type(capability))
func(Capability.COLOR_CONTROL)
func("colorControl")
colorControl <enum 'Capability'> colorControl <class 'str'> I have tests for this fix in my stack, but it looks like I split the tests for this change into a different commit Ideally we could narrow to a literal, but in general mypy is missing a bunch of logic around the values of enums |
Sorry, something went wrong.
|
#20672 includes more tests here |
Sorry, something went wrong.
Good point, missed that! Thanks for working on it. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR should not change semantics
We refactor to avoid the separate loops for type_targets and value_targets, which allows the logic to be more consolidated, helps with future changes and is probably faster