Skip to content

Full signature for namedtuple - #541

Merged
gvanrossum merged 9 commits into
python:masterfrom
elazarg:nt_sig
Sep 13, 2016
Merged

gvanrossum merged 9 commits into
python:masterfrom
elazarg:nt_sig

Conversation

@elazarg

@elazarg elazarg commented Sep 13, 2016 •

Copy link
Copy Markdown
Contributor

Issue #533

Comment thread stdlib/3/typing.pyi

# 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
Copy Markdown
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
Copy Markdown
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

elazarg commented Sep 13, 2016

Copy link
Copy Markdown
Contributor Author

(NamedTuple definition moved down to allow using Iterable)

@gvanrossum

Copy link
Copy Markdown
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).

Comment thread stdlib/3/typing.pyi Outdated
# 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
Copy Markdown
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
Copy Markdown
Member

There's also 2.7/typing.pyi.

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

Copy link
Copy Markdown
Member

Fingers crossed!

hswong3i pushed a commit to alvistack/python-typeshed that referenced this pull request May 25, 2025
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
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