Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(🎁) Support setter defined on subtype #15654

Closed
KotlinIsland opened this issue Jul 13, 2023 · 1 comment
Closed

(🎁) Support setter defined on subtype #15654

KotlinIsland opened this issue Jul 13, 2023 · 1 comment
Labels

Comments

@KotlinIsland
Copy link
Contributor

class A:
    @property
    def foo(self) -> str:
        return "hi"
class B(A):
    @A.foo.setter  # "(A) -> str" has no attribute "setter"  [attr-defined]
    def foo(self, value: str):
        print(value)
B().foo = "a"
B().foo = 1  # no error

Workaround

Define additional prop getter in derived class

class A:
    @property
    def foo(self) -> str:
        return "hi"
class B(A):
    @property
    def foo(self)-> str:
        return super().foo
    @foo.setter
    def foo(self, value: str):
        print(value)
B().foo = "a"
B().foo = 1  # yes error
@A5rocks
Copy link
Collaborator

A5rocks commented Jan 24, 2025

Duplicate of #1465. (or #5936... wow we have a lot of duplicates)

@A5rocks A5rocks closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants