FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[2.4 regression] Property getter body is not type-checked when the setter assigns to `self` · Issue #22229 · python/mypy · GitHub

Repository navigation

[2.4 regression] Property getter body is not type-checked when the setter assigns to self #22229

Closed

Description

Bug Report

Since 2.4.0, errors in the body of a property getter are no longer reported when the property's setter assigns an attribute on self.
Same result when the attribute is declared in the class body (e.g. x = 0).

To Reproduce

class A:
    @property
    def p(self) -> str:
        return 0

    @p.setter
    def p(self, value: int) -> None:
        self.x = value

Expected Behavior

As with mypy 2.3.0:

main.py:4: error: Incompatible return value type (got "int", expected "str")  [return-value]
Found 1 error in 1 file (checked 1 source file)

See playground

Actual Behavior

Success: no issues found in 1 source file

See playground

Your Environment

  • Mypy version used: 2.4.0, also master (45b9b1d)
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.11 and 3.14

Activity

  1. ilevkivskyi commented on Oct 19, 2026

    Member

    There is a chance this is caused by the two-phase type-checking. I will take a look.

  2. UnknownPlatypus commented on Oct 20, 2026

    Author

    that was quick, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL