Visitar URL original
typings: Pass variable as final · Issue #113654 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20250621113854/https://github.com/python/cpython/issues/113654
Skip to content

typings: Pass variable as final #113654

Closed as not planned
Closed as not planned
@cojmeister

Description

@cojmeister

Feature or enhancement

Proposal:

The idea is to be able to pass variables as constants, mimicking c++ or rust behaviour such as. And have this be solely as part of the typings ecosystem. It's extremely helpful when reviewing code, or starting to use new codebases.

fn my_function(mut changeable: &String, unchangeable: &String) {}

In python I suggest the following:

def my_function(changeable: str, unchangeable: Final[str])-> None:
    arguments_that_changes += "world!"
    return arguments_that_changes + argument_that_stays_constant

Has this already been discussed elsewhere?

Opened issue in typing repo as well: #1557

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions