-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
namedtuple should support "module" parameter added in Python 3.6 #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The current definition is wrong. From
Well, no. Even when it is special cased by the type checker, for uniformity it might want to use the actual signature; currently this is done ad-hoc and incorrectly in mypy:
The last error message does not happen with correct signature in (It might even be helpful to add a pseudo-implementation, so that type checkers can simply inline and continue, getting rough approximation of the actual type. This is not like adding implementation of arbitrary functions, as this is a type constructor with trivial control flow) |
I think this would be reasonable to put in the stub: # namedtuple is special-cased in the type checker; the initializer is ignored.
def namedtuple(typename: str, field_names: Union[str, Iterable[Any]], *,
verbose: bool = False, rename: bool = False, module: bool = None) -> Type[tuple]: ... but we also need to add support for the keyword args to mypy. Can you file a separate bug for that? I'm happy to take a PR for the above. |
I assume you mean While we're at it, perhaps we should add
But I don't know if that's valid. |
Just send a PR already. :-) On Tue, Sep 13, 2016 at 9:51 AM, Elazar [email protected] wrote:
--Guido van Rossum (python.org/~guido) |
Fixed by #541. (If you want to do cast() and NewType() too, just submit another PR.) |
See http://bugs.python.org/issue17941
The text was updated successfully, but these errors were encountered: