Skip to content

Full signature for namedtuple #541

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

Merged
merged 9 commits into from
Sep 13, 2016
Merged

Full signature for namedtuple #541

merged 9 commits into from
Sep 13, 2016

Conversation

elazarg
Copy link
Contributor

@elazarg elazarg commented Sep 13, 2016

Issue #533


# NamedTuple is special-cased in the type checker; the initializer is ignored.
def NamedTuple(typename: str, fields: Iterable[Tuple[str, Any]], *,
verbose: bool = ..., rename: bool = ..., module: str = None) -> Type[tuple]: ...
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fields can be more exact as Iterable[Tuple[str, Union[str, Type]]] or something like that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, a type annotation doesn't have to be a type (see python/typing#136). So better leave this as is, or use Union[str, Any].

@elazarg
Copy link
Contributor Author

elazarg commented Sep 13, 2016

(NamedTuple definition moved down to allow using Iterable)

@gvanrossum
Copy link
Member

Can you also do these for 2.7?

Also, please be careful about not adding extra blank lines (read your own review to find where they are).

# NamedTuple is special-cased in the type checker; the initializer is ignored.
def NamedTuple(typename: str, fields: Iterable[Tuple[str, Any]], *,
verbose: bool = ..., rename: bool = ..., module: str = None) -> Type[tuple]: ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kill this blank line please.

@gvanrossum
Copy link
Member

There's also 2.7/typing.pyi.

@gvanrossum gvanrossum merged commit e25b882 into python:master Sep 13, 2016
@gvanrossum
Copy link
Member

Fingers crossed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants