| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This basically follows the approach Jukka laid out in #1020 four years ago: * If the return type is Any, ignore that and keep the class type as the return type * Otherwise respect `__new__`'s return type * Produce an error if the return type is not a subtype of the class. The main motivation for me in implementing this is to support overloading `__new__` in order to select type variable arguments, which will be useful for subprocess.Popen. Fixes #1020.
There was a problem hiding this comment.
Thanks! Generally looks good, but there is one suspicious place.
How hard would be to support a similar feature for __init__? (Like in my comment on typeshed.) Essentially, people often implement such logic (type argument specification) in __init__, see an important example #4236 (default value for type variable).
Sorry, something went wrong.
| variables.extend(info.defn.type_vars) | ||
| variables.extend(init_type.variables) | ||
|
|
||
| is_new = True |
There was a problem hiding this comment.
This looks suspicious for two reasons:
Sorry, something went wrong.
There was a problem hiding this comment.
Oh hm. That was testing code that survived because it works without it, since NoneTyp won't trigger the isinstance check...
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This basically follows the approach Jukka laid out in #1020 four years ago:
the return type
The main motivation for me in implementing this is to support
overloading __new__ in order to select type variable arguments,
which will be useful for subprocess.Popen.
Fixes #1020.