Skip to content

typechecked not compatible with class property decorator #355

@Jonas1312

Description

@Jonas1312

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Typeguard version

4

Bug is not present with typeguard v2

Python version

3.7

What happened?

The code below raises:

    obj.a = "2"
TypeError: a() takes 1 positional argument but 2 were given

How can we reproduce the bug?

from typeguard import typechecked


class MyClass:
    def __init__(self) -> None:
        self._a = "1"

    @property
    def a(self) -> str:
        return self._a

    @a.setter
    @typechecked
    def a(self, a: str) -> None:
        self._a = a


obj = MyClass()
print(obj.a)
obj.a = "2"
print(obj.a)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions