Skip to content

Type stub for a property setter that is supposed to normalise its input into but is unsafe #861

Answered by Akuli
Sam-Martin asked this question in Q&A
Discussion options

You must be logged in to vote

This is a known mypy bug: python/mypy#3004

A decent workaround would be Any | DefaultDynamicNaming. It's not great for the setter, because it means that any object is accepted. But for the getter, it is not same as just Any like you might expect: if you do value_from_getter.foo for example, mypy will complain that DefaultDynamicNaming has no attribute foo, because it would be valid only if both union members had that attribute.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Sam-Martin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants