Skip to content

[1.16 regression] Relative order of property methods changes mypy output #19224

Closed
@gpauloski

Description

@gpauloski

Bug Report

In mypy 1.16, the relative ordering of property methods (i.e., getter/setter/deleter) can produce an "Invalid property setter signature" error.

To Reproduce

mypy playground with the same example

Having an @deleter or @getter before a @setter property method produces an error:

class C:
    _value: int = 0

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

    @value.deleter
    def value(self) -> None: ...  # error: Invalid property setter signature  [misc]

    @value.setter
    def value(self, v: int) -> None: ...
$ mypy t.py
main.py:9: error: Invalid property setter signature  [misc]
Found 1 error in 1 file (checked 1 source file)

Move the @value.deleter method to after @value.setter and the error is fixed.

class C:
    _value: int = 0

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

    @value.setter
    def value(self, v: int) -> None: ...

    @value.deleter
    def value(self) -> None: ...
$ mypy t.py
Success: no issues found in 1 source file

Expected Behavior

The relative ordering should not alter the output of mypy. I'm not aware of any reason why the ordering should matter and all orderings pass mypy in 1.15.

Your Environment

  • Mypy version used: 1.16
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-descriptorsProperties, class vs. instance attributes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions