This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Make @final introspectable at runtime
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: JelleZijlstra Nosy List: AlexWaygood, JelleZijlstra, gvanrossum, kj
Priority: normal Keywords: patch

Created on 2022-01-11 12:10 by JelleZijlstra, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30530 merged JelleZijlstra, 2022-01-11 12:34
Messages (2)
msg410298 - (view) Author: Jelle Zijlstra (JelleZijlstra) * (Python committer) Date: 2022-01-11 12:10
Currently, @typing.final is implemented as an identity function, which makes it impossible for type checkers that look at runtime objects to support it.

I propose that we implement it as something like:

    def final(f):
        try:
            f.__final__ = True
        except AttributeError:
            pass  # in case it is used on an object that doesn't support setting attributes
        return f

I will submit a PR implementing this idea.
msg410424 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2022-01-12 19:38
New changeset 0bbf30e2b910bc9c5899134ae9d73a8df968da35 by Jelle Zijlstra in branch 'main':
bpo-46342: make @typing.final introspectable (GH-30530)
https://github.com/python/cpython/commit/0bbf30e2b910bc9c5899134ae9d73a8df968da35
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90500
2022-01-12 22:05:14AlexWaygoodsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-01-12 19:38:33gvanrossumsetmessages: + msg410424
2022-01-11 12:42:24AlexWaygoodsetnosy: + AlexWaygood
2022-01-11 12:34:10JelleZijlstrasetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request28732
2022-01-11 12:10:25JelleZijlstracreate