| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…future annotations
|
|
||
| base_type_params = getattr(typ, "__type_params__", ()) | ||
| for btp in base_type_params: | ||
| if btp.__name__ in seen: |
There was a problem hiding this comment.
this seems wrong, base classes can have another type param with the same name
Sorry, something went wrong.
|
This likely still returns wrong results and/or throws NameError if a stringified annotation refers to a (non-type param) name that is defined in the base class's module but not the child class's. I think to do this fully correctly we'd have to add some data at TypedDict creation time: an annotation dict with just the TypedDict's own non-inherited annotations (own_annotations?) and the actual MRO (__typeddict_mro__?). The latter can already be reconstructed right now (as your code shows), but I don't think the former can be. It's not enough to e.g. look at which annotations exist in base classes, because the child class might override a base class annotation for the same name. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This looks a bit messy, any suggestions on we can make this simplier are welcome.
It is really bad that TypedDict classes do not create correct __mro__ and just copies all annotations :(