Skip to content

Return type of property setters is not checked #20513

@decorator-factory

Description

@decorator-factory

Example code:

class Banana:
    @property
    def size(self) -> int:
        return 42

    @size.setter
    async def size(self, value: int, /) -> None:
        print(f"set value to {value!r}")

b = Banana()
b.size = 42

I expected mypy to complain that the setter function doesn't return None and returns Coroutine[Any, Any, None] instead. Similarly, if the setter is a non-async function returning e.g. str or int, no error is reported.

Environment

  • Mypy version used: 1.19.1
  • Mypy command-line flags: --strict
  • Python version used: 3.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions