Skip to content

Fixes __init__ of typing.NamedTuple - #6080

Merged
hauntsaninja merged 2 commits into
python:masterfrom
sobolevn:patch-14
Sep 29, 2021
Merged

hauntsaninja merged 2 commits into
python:masterfrom
sobolevn:patch-14

Conversation

@sobolevn

@sobolevn sobolevn commented Sep 26, 2021 •

Copy link
Copy Markdown
Member

Two things to discuss:

  1. (Iterable[Tuple[str, Any]] and kwargs: Any) or (Iterable[Tuple[str, type]] and kwargs: type)
  2. Do we need fields: None = ... in the second overload?

Closes #6079

@github-actions

This comment has been minimized.

@JelleZijlstra

Copy link
Copy Markdown
Member

I think @srittau accidentally edited your comment instead of responding to your questions. I restored your original comment (approximately, couldn't find the raw markdown). Here are my thoughts:

(Iterable[Tuple[str, Any]] and kwargs: Any) or (Iterable[Tuple[str, type]] and kwargs: type)

I'd say the former. Not all acceptable types are actually types.

Do we need fields: None = ... in the second overload?

Yes, because fields=None is legal at runtime.

@sobolevn

Copy link
Copy Markdown
Member Author

@JelleZijlstra done! I agree with fields=None and type after writting so many tests in python/mypy#11206 😆

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@hauntsaninja
hauntsaninja merged commit 4ac969a into python:master Sep 29, 2021
@sobolevn

Copy link
Copy Markdown
Member Author

Thanks everyone! 🎉

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.

Fix __init__ type of typing.NamedTuple

3 participants