Skip to content

overloaded function has no attribute "fset" error when attempting to assign to base class's setter #16426

New issue

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

By clicking “No 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? No Sign in to your account

Open
DetachHead opened this issue Nov 9, 2023 · 0 comments
Labels
bug mypy got something wrong

Comments

@DetachHead
Copy link
Contributor

class Foo:
    def __init__(self) -> None:
        self._value = 1

    @property
    def value(self) -> int:
        return self._value

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


class Bar(Foo):
    @property
    def value(self) -> int:
        return super().value

    @value.setter
    def value(self, new_value: int) -> None:
        Foo.value.fset(self, new_value) # error: overloaded function has no attribute "fset"  [attr-defined]

playground

this is working around the fact that assigning to super().value doesn't work at runtime:

super().value = new_value  # error: Invalid assignment target [misc]
@DetachHead DetachHead added the bug mypy got something wrong label Nov 9, 2023
RoDuth added a commit to RoDuth/ghini.desktop that referenced this issue Nov 16, 2024
Now type annotations are more commonly added than not fix mypy issues.
Some of this is scrappy and would be better dealt with by upgrading to
sqlalchemy 2 etc..

OsmGpsMap [attr-defined] import error only when run on the file itself
not the whole repo?

prefs.testing = True not needed in most situtations and hence removed.

Removed a couple of monkey patches in tests, use mock instead

Removed unused monkey patching of models to db.

Some context:
python/typing#1102
sqlalchemy/sqlalchemy#9321
python/mypy#16426
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant