Skip to content

Regression: Cannot combine @property decorator with @abstractclassmethod #7134

Closed
@erictraut

Description

@erictraut

This commit changed the definition of abstractclassmethod and abstractstaticmethod in a way that makes them no longer callable. That means they cannot be used with other decorators (like property) that require a callable.

The following previously type checked without errors, but it no longer works.

    @property
    @abc.abstractclassmethod
    def foo(self) -> str: ...

The new declaration of abstractclassmethod and abstractstaticmethod also completely obscure the signature of the function they're decorating, which is a big problem for type checking (and completion suggestions, etc.).

I recommend reverting the change for abstractclassmethod and abstractstaticmethod. If there is a compelling reason to wrap these in a class, then the class should be parameterized with a ParamSpec and should include a __call__ method so it is still callable. @srittau, do you have a preference?

I won't be able to incorporate the latest typeshed stubs into pyright or pylance until this is addressed because this regression results in significant problems for internal Microsoft code bases.

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