Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Docs: UpdateTypedDict import statements#16958

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 4 commits intopython:masterfromrdimaio:patch-1
Feb 29, 2024

Conversation

@rdimaio
Copy link
Contributor

Since Python 3.8,TypedDict has been available from thetyping module.

As Python 3.8+ is needed to use mypy (https://github.com/python/mypy/blob/master/setup.py#L12), then it's best for the docs to reflect Python 3.8+ usage.

For previous versions, there's already a disclaimer on the page that explains thattyping_extensions must be used:https://github.com/python/mypy/blob/master/docs/source/typed_dict.rst?plain=1#L102-L110

Since Python 3.8, `TypedDict` has been available from the `typing` module. As Python 3.8+ is needed to use mypy (https://github.com/python/mypy/blob/master/setup.py#L12), then it's best for the docs to reflect Python 3.8+ usage.For previous versions, there's already a disclaimer on the page that explains that `typing_extensions` must be used:https://github.com/python/mypy/blob/master/docs/source/typed_dict.rst?plain=1#L102-L110
Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks! Looks like we have a bunch offrom typing_extensions import Literal andfrom typing_extensions import Protocol instances scattered across the docs as well -- want to update those at the same time?

rdimaio reacted with thumbs up emoji
Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks! Nearly there

# Use "mypy --enable-error-code unimported-reveal"
from typingimport reveal_type#or `typing_extensions`
from typingimport reveal_type#"fromtyping_extensions" in Python 3.10 and earlier
Copy link
Member

Choose a reason for hiding this comment

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

I think this one can be left as-is: the existing message is more concise, and isn't incorrect (you can still import it fromtyping_extensions on 3.11+)

example.py:3: error: "bool" is invalid as return type for "__exit__" that always returns False
example.py:3: note: Use "typing_extensions.Literal[False]" as the return type or change it to
example.py:3: note: Use "typing.Literal[False]" as the return type or change it to
Copy link
Member

Choose a reason for hiding this comment

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

We should update the error message mypy emits here, but until we do so, we shouldn't change the docs here: this copies exactly the error message mypy emits on the above snippethttps://mypy-play.net/?mypy=latest&python=3.12&gist=aab6f1cc25003dd1573cb3d8b8df2396

Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks!

rdimaio reacted with hooray emoji
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@JelleZijlstraJelleZijlstra merged commit02c50bc intopython:masterFeb 29, 2024
@rdimaiordimaio deleted the patch-1 branchFebruary 29, 2024 15:49
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JelleZijlstraJelleZijlstraAwaiting requested review from JelleZijlstra

1 more reviewer

@AlexWaygoodAlexWaygoodAlexWaygood approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@rdimaio@AlexWaygood@JelleZijlstra

[8]ページ先頭

©2009-2025 Movatter.jp