Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make @final introspectable at runtime #90500

Closed
JelleZijlstra opened this issue Jan 11, 2022 · 2 comments
Closed

Make @final introspectable at runtime #90500

JelleZijlstra opened this issue Jan 11, 2022 · 2 comments
Assignees
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@JelleZijlstra
Copy link
Member

BPO 46342
Nosy @gvanrossum, @JelleZijlstra, @Fidget-Spinner, @AlexWaygood
PRs
  • bpo-46342: make @typing.final introspectable #30530
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/JelleZijlstra'
    closed_at = <Date 2022-01-12.22:05:14.069>
    created_at = <Date 2022-01-11.12:10:25.536>
    labels = ['type-feature', 'library', '3.11']
    title = 'Make @final introspectable at runtime'
    updated_at = <Date 2022-01-12.22:05:14.069>
    user = 'https://github.com/JelleZijlstra'

    bugs.python.org fields:

    activity = <Date 2022-01-12.22:05:14.069>
    actor = 'AlexWaygood'
    assignee = 'JelleZijlstra'
    closed = True
    closed_date = <Date 2022-01-12.22:05:14.069>
    closer = 'AlexWaygood'
    components = ['Library (Lib)']
    creation = <Date 2022-01-11.12:10:25.536>
    creator = 'JelleZijlstra'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46342
    keywords = ['patch']
    message_count = 2.0
    messages = ['410298', '410424']
    nosy_count = 4.0
    nosy_names = ['gvanrossum', 'JelleZijlstra', 'kj', 'AlexWaygood']
    pr_nums = ['30530']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue46342'
    versions = ['Python 3.11']

    @JelleZijlstra
    Copy link
    Member Author

    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.

    @JelleZijlstra JelleZijlstra added the 3.11 only security fixes label Jan 11, 2022
    @JelleZijlstra JelleZijlstra self-assigned this Jan 11, 2022
    @JelleZijlstra JelleZijlstra added stdlib Python modules in the Lib dir type-feature A feature request or enhancement 3.11 only security fixes labels Jan 11, 2022
    @JelleZijlstra JelleZijlstra self-assigned this Jan 11, 2022
    @JelleZijlstra JelleZijlstra added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jan 11, 2022
    @gvanrossum
    Copy link
    Member

    New changeset 0bbf30e by Jelle Zijlstra in branch 'main':
    bpo-46342: make @typing.final introspectable (GH-30530)
    0bbf30e

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants