Skip to content

Pyright reports redeclaration when using types.DynamicClassAttribute after typeshed change #9620

@tungol

Description

@tungol

Describe the bug
Currently, typeshed declares DynamicClassAttribute as an alias of property:

DynamicClassAttribute = property

I'd like to update this to define DynamicClassAttribute as it's own class. The new mypy 1.14.0 supports this change, but pyright is generating reportRedeclaration errors when declaring setters and deleters if this change is made.

Code or Screenshots

See the typeshed MR with the change and a test showing the pyright errors: python/typeshed#13276

test case:

class DCAtest:
    _value: int | None = None

    @types.DynamicClassAttribute
    def foo(self) -> int | None:
        return self._value

    @foo.setter
    def foo(self, value: int) -> None:
        self._value = value

    @foo.deleter
    def foo(self) -> None:
        self._value = None

Metadata

Metadata

Assignees

No one assigned

    Labels

    as designedNot a bug, working as intendedbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions