Skip to content

typing.final supports properties #5984

Description

@twoertwein

PEP 591: "The method decorator version may be used with all of instance methods, class methods, static methods, and properties."

fromtypingimportfinalclassTest:
@final@propertydefbar(self):
return"bar"

But typing.final is currently annotated as requiring a Callable:

deffinal(f: _F) ->_F: ...

pyright rejects the above code since it is using the typeshed annotations (mypy accepts it for some reason).

error: Argument of type "property" cannot be assigned to parameter "f" of type "_F@final" in function "final"
Type "property" is incompatible with bound type "(*args: Any, **kwargs: Any) -> Any" for type variable "_F@final"
Type "property" cannot be assigned to type "(*args: Any, **kwargs: Any) -> Any" (reportGeneralTypeIssues)

xref microsoft/pyright#2242 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions