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

Error message for assigning to property refers to wrong class #4756

Closed
ilevkivskyi opened this Issue Mar 19, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@ilevkivskyi
Collaborator

ilevkivskyi commented Mar 19, 2018

Consider this example:

class C:
    @property
    def foo(self) -> int:
        return 17
class D(C):
    pass
d = D()
d.foo = 18  # error: Property "foo" defined in "D" is read-only

The error should better say defined in "C".

Michael0x2a added a commit to Michael0x2a/mypy that referenced this issue Apr 5, 2018

Fix error message when assigning to read-only property
Fixes python#4756

Consider the following program:

```python
class Parent:
    @Property
    def foobar(self) -> int: ...

class Child(Parent): pass

Child().foobar = 10
```

Previously, mypy would report that the property `foobar` was defined in
'Child'. Now, it correctly reports it was defined in 'Parent'.

ilevkivskyi added a commit that referenced this issue Apr 5, 2018

Fix error message when assigning to read-only property (#4863)
Fixes #4756

Consider the following program:
```
class Parent:
    @Property
    def foobar(self) -> int: ...

class Child(Parent): pass

Child().foobar = 10
```

Previously, mypy would report that the property `foobar` was defined in
'Child'. Now, it correctly reports it was defined in 'Parent'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment