FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-46342: make @typing.final introspectable by JelleZijlstra · Pull Request #30530 · python/cpython · GitHub

/ cpython Public

bpo-46342: make @typing.final introspectable - #30530

Merged
gvanrossum merged 4 commits into
python:mainfrom
JelleZijlstra:issue46342
Jan 12, 2022
Merged

bpo-46342: make @typing.final introspectable#30530
gvanrossum merged 4 commits into
python:mainfrom
JelleZijlstra:issue46342

Conversation

JelleZijlstra commented Jan 11, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Comment thread Lib/typing.py
"""
try:
f.__final__ = True
except (AttributeError, TypeError):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'd be open to just doing just except Exception here, in case some type throws a different exception if you try to set an attribute. For precedent, note that @no_type_check catches only TypeError.

Copy link
Copy Markdown
Member

LGTM.
Side question: I'm curious as to which runtime type checkers use this information/What inspired you to make this change?

Copy link
Copy Markdown
Member Author

quora/pyanalyze#161. My type checker, pyanalyze, imports modules it typechecks and uses the runtime objects for checking. With this change, I can make it show an error if you inherit from something @final.

Fidget-Spinner left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Some minor nits

Comment thread Doc/library/typing.rst Outdated
JelleZijlstra and others added 2 commits January 11, 2022 06:06
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Comment thread Lib/typing.py

gvanrossum left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sounds like a good idea. I trust the current participants to come up with the right thing. Let me know when you all agree and you want me to merge it.

Fidget-Spinner left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. Thanks Jelle.

gvanrossum merged commit 0bbf30e into python:main Jan 12, 2022
JelleZijlstra deleted the issue46342 branch January 12, 2022 19:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

6 participants


Back | FazBrowse Home | New Git URL