-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Property setter not accepted if not next to getter #1465
Comments
We get little benefit from our mypy QA checks at the moment, because we skip imports. This patch is what's needed to make mypy succeed with imports on a single file: master.py It also updates mypy to the current version, and enables a QA check. Mypy bugs I encountered: dict.update with kwargs not supported: python/mypy#1031 property setters and getters must be adjacent: python/mypy#1465
We get little benefit from our mypy QA checks at the moment, because we skip imports. This patch is what's needed to make mypy succeed with imports on a single file: master.py It also updates mypy to the current version, and enables a QA check. Mypy bugs I encountered: dict.update with kwargs not supported: python/mypy#1031 property setters and getters must be adjacent: python/mypy#1465
We get little benefit from our mypy QA checks at the moment, because we skip imports. This patch is what's needed to make mypy succeed with imports on a single file: master.py It also updates mypy to the current version, and enables a QA check. Mypy bugs I encountered: dict.update with kwargs not supported: python/mypy#1031 property setters and getters must be adjacent: python/mypy#1465
We get little benefit from our mypy QA checks at the moment, because we skip imports. This patch is what's needed to make mypy succeed with imports on a single file: master.py It also updates mypy to the current version, and enables a QA check. Mypy bugs I encountered: dict.update with kwargs not supported: python/mypy#1031 property setters and getters must be adjacent: python/mypy#1465
We get little benefit from our mypy QA checks at the moment, because we skip imports. This patch is what's needed to make mypy succeed with imports on a single file: master.py It also updates mypy to the current version, and enables a QA check. Mypy bugs I encountered: dict.update with kwargs not supported: python/mypy#1031 property setters and getters must be adjacent: python/mypy#1465
We get little benefit from our mypy QA checks at the moment, because we skip imports. This patch is what's needed to make mypy succeed with imports on a single file: master.py It also updates mypy to the current version, and enables a QA check. Mypy bugs I encountered: dict.update with kwargs not supported: python/mypy#1031 property setters and getters must be adjacent: python/mypy#1465
We get little benefit from our mypy QA checks at the moment, because we skip imports. This patch is what's needed to make mypy succeed with imports on a single file: master.py It also updates mypy to the current version, and enables a QA check. Mypy bugs I encountered: dict.update with kwargs not supported: python/mypy#1031 property setters and getters must be adjacent: python/mypy#1465
We get little benefit from our mypy QA checks at the moment, because we skip imports. This patch is what's needed to make mypy succeed with imports on a single file: master.py It also updates mypy to the current version, and enables a QA check. Mypy bugs I encountered: dict.update with kwargs not supported: python/mypy#1031 property setters and getters must be adjacent: python/mypy#1465
#1713 has another example and some ideas. |
What is the status of this issue? #1713 is closed as duplicate of this issue. |
We don't have immediate plans for fix this issue, but we are happy to receive a PR. |
I had missed that moving the setter next to getter solves the problem, which is good enough. Thanks for the update! |
This also affects subclasses that override properties, e.g.: class Parent(object):
@property
def foo(self):
return "parent_foo"
class Child(Parent):
@Parent.foo.getter
def foo(self):
return "child_foo" mypy returns a |
workaround for mypy issue: python/mypy#1465 fixes mypy errors: volumes/fs/operations/group.py: note: In class "Group": volumes/fs/operations/group.py:44: error: Name 'uid' already defined on line 36 volumes/fs/operations/group.py:44: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py:48: error: Name 'gid' already defined on line 40 volumes/fs/operations/group.py:48: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py: note: In function "open_group": volumes/fs/operations/group.py:170: error: Property "uid" defined in "Group" is read-only volumes/fs/operations/group.py:171: error: Property "gid" defined in "Group" is read-only volumes/fs/operations/versions/subvolume_base.py: note: In class "SubvolumeBase": volumes/fs/operations/versions/subvolume_base.py:45: error: Name 'uid' already defined on line 33 volumes/fs/operations/versions/subvolume_base.py:45: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:49: error: Name 'gid' already defined on line 37 volumes/fs/operations/versions/subvolume_base.py:49: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:53: error: Name 'mode' already defined on line 41 volumes/fs/operations/versions/subvolume_base.py:53: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" Signed-off-by: Michael Fritch <mfritch@suse.com>
workaround for mypy issue: python/mypy#1465 fixes mypy errors: volumes/fs/operations/group.py: note: In class "Group": volumes/fs/operations/group.py:44: error: Name 'uid' already defined on line 36 volumes/fs/operations/group.py:44: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py:48: error: Name 'gid' already defined on line 40 volumes/fs/operations/group.py:48: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py: note: In function "open_group": volumes/fs/operations/group.py:170: error: Property "uid" defined in "Group" is read-only volumes/fs/operations/group.py:171: error: Property "gid" defined in "Group" is read-only volumes/fs/operations/versions/subvolume_base.py: note: In class "SubvolumeBase": volumes/fs/operations/versions/subvolume_base.py:45: error: Name 'uid' already defined on line 33 volumes/fs/operations/versions/subvolume_base.py:45: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:49: error: Name 'gid' already defined on line 37 volumes/fs/operations/versions/subvolume_base.py:49: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:53: error: Name 'mode' already defined on line 41 volumes/fs/operations/versions/subvolume_base.py:53: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" Signed-off-by: Michael Fritch <mfritch@suse.com>
workaround for mypy issue: python/mypy#1465 fixes mypy errors: volumes/fs/operations/group.py: note: In class "Group": volumes/fs/operations/group.py:44: error: Name 'uid' already defined on line 36 volumes/fs/operations/group.py:44: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py:48: error: Name 'gid' already defined on line 40 volumes/fs/operations/group.py:48: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py: note: In function "open_group": volumes/fs/operations/group.py:170: error: Property "uid" defined in "Group" is read-only volumes/fs/operations/group.py:171: error: Property "gid" defined in "Group" is read-only volumes/fs/operations/versions/subvolume_base.py: note: In class "SubvolumeBase": volumes/fs/operations/versions/subvolume_base.py:45: error: Name 'uid' already defined on line 33 volumes/fs/operations/versions/subvolume_base.py:45: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:49: error: Name 'gid' already defined on line 37 volumes/fs/operations/versions/subvolume_base.py:49: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:53: error: Name 'mode' already defined on line 41 volumes/fs/operations/versions/subvolume_base.py:53: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" Signed-off-by: Michael Fritch <mfritch@suse.com>
workaround for mypy issue: python/mypy#1465 fixes mypy errors: volumes/fs/operations/group.py: note: In class "Group": volumes/fs/operations/group.py:44: error: Name 'uid' already defined on line 36 volumes/fs/operations/group.py:44: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py:48: error: Name 'gid' already defined on line 40 volumes/fs/operations/group.py:48: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py: note: In function "open_group": volumes/fs/operations/group.py:170: error: Property "uid" defined in "Group" is read-only volumes/fs/operations/group.py:171: error: Property "gid" defined in "Group" is read-only volumes/fs/operations/versions/subvolume_base.py: note: In class "SubvolumeBase": volumes/fs/operations/versions/subvolume_base.py:45: error: Name 'uid' already defined on line 33 volumes/fs/operations/versions/subvolume_base.py:45: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:49: error: Name 'gid' already defined on line 37 volumes/fs/operations/versions/subvolume_base.py:49: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:53: error: Name 'mode' already defined on line 41 volumes/fs/operations/versions/subvolume_base.py:53: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" Signed-off-by: Michael Fritch <mfritch@suse.com>
workaround for mypy issue: python/mypy#1465 fixes mypy errors: volumes/fs/operations/group.py: note: In class "Group": volumes/fs/operations/group.py:44: error: Name 'uid' already defined on line 36 volumes/fs/operations/group.py:44: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py:48: error: Name 'gid' already defined on line 40 volumes/fs/operations/group.py:48: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py: note: In function "open_group": volumes/fs/operations/group.py:170: error: Property "uid" defined in "Group" is read-only volumes/fs/operations/group.py:171: error: Property "gid" defined in "Group" is read-only volumes/fs/operations/versions/subvolume_base.py: note: In class "SubvolumeBase": volumes/fs/operations/versions/subvolume_base.py:45: error: Name 'uid' already defined on line 33 volumes/fs/operations/versions/subvolume_base.py:45: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:49: error: Name 'gid' already defined on line 37 volumes/fs/operations/versions/subvolume_base.py:49: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:53: error: Name 'mode' already defined on line 41 volumes/fs/operations/versions/subvolume_base.py:53: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" Signed-off-by: Michael Fritch <mfritch@suse.com>
workaround for mypy issue: python/mypy#1465 fixes mypy errors: volumes/fs/operations/group.py: note: In class "Group": volumes/fs/operations/group.py:44: error: Name 'uid' already defined on line 36 volumes/fs/operations/group.py:44: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py:48: error: Name 'gid' already defined on line 40 volumes/fs/operations/group.py:48: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py: note: In function "open_group": volumes/fs/operations/group.py:170: error: Property "uid" defined in "Group" is read-only volumes/fs/operations/group.py:171: error: Property "gid" defined in "Group" is read-only volumes/fs/operations/versions/subvolume_base.py: note: In class "SubvolumeBase": volumes/fs/operations/versions/subvolume_base.py:45: error: Name 'uid' already defined on line 33 volumes/fs/operations/versions/subvolume_base.py:45: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:49: error: Name 'gid' already defined on line 37 volumes/fs/operations/versions/subvolume_base.py:49: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:53: error: Name 'mode' already defined on line 41 volumes/fs/operations/versions/subvolume_base.py:53: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" Signed-off-by: Michael Fritch <mfritch@suse.com>
workaround for mypy issue: python/mypy#1465 fixes mypy errors: volumes/fs/operations/group.py: note: In class "Group": volumes/fs/operations/group.py:44: error: Name 'uid' already defined on line 36 volumes/fs/operations/group.py:44: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py:48: error: Name 'gid' already defined on line 40 volumes/fs/operations/group.py:48: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py: note: In function "open_group": volumes/fs/operations/group.py:170: error: Property "uid" defined in "Group" is read-only volumes/fs/operations/group.py:171: error: Property "gid" defined in "Group" is read-only volumes/fs/operations/versions/subvolume_base.py: note: In class "SubvolumeBase": volumes/fs/operations/versions/subvolume_base.py:45: error: Name 'uid' already defined on line 33 volumes/fs/operations/versions/subvolume_base.py:45: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:49: error: Name 'gid' already defined on line 37 volumes/fs/operations/versions/subvolume_base.py:49: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:53: error: Name 'mode' already defined on line 41 volumes/fs/operations/versions/subvolume_base.py:53: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" Fixes: https://tracker.ceph.com/issues/44393 Signed-off-by: Michael Fritch <mfritch@suse.com>
workaround for mypy issue: python/mypy#1465 fixes mypy errors: volumes/fs/operations/group.py: note: In class "Group": volumes/fs/operations/group.py:44: error: Name 'uid' already defined on line 36 volumes/fs/operations/group.py:44: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py:48: error: Name 'gid' already defined on line 40 volumes/fs/operations/group.py:48: error: "Callable[[Group], Any]" has no attribute "setter" volumes/fs/operations/group.py: note: In function "open_group": volumes/fs/operations/group.py:170: error: Property "uid" defined in "Group" is read-only volumes/fs/operations/group.py:171: error: Property "gid" defined in "Group" is read-only volumes/fs/operations/versions/subvolume_base.py: note: In class "SubvolumeBase": volumes/fs/operations/versions/subvolume_base.py:45: error: Name 'uid' already defined on line 33 volumes/fs/operations/versions/subvolume_base.py:45: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:49: error: Name 'gid' already defined on line 37 volumes/fs/operations/versions/subvolume_base.py:49: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" volumes/fs/operations/versions/subvolume_base.py:53: error: Name 'mode' already defined on line 41 volumes/fs/operations/versions/subvolume_base.py:53: error: "Callable[[SubvolumeBase], Any]" has no attribute "setter" Fixes: https://tracker.ceph.com/issues/44393 Signed-off-by: Michael Fritch <mfritch@suse.com>
This problem seems to be persistent and still confuses people a lot maybe it's time to fix it? |
* This is a mypy issue: python/mypy#1465 Mypy reports false positive when a decorated setter isn't declare right above its getter.
* This is a mypy issue: python/mypy#1465 Mypy reports false positive when a decorated setter isn't declare right above its getter.
Thanks for posting this - also struggling with this. Is there any known workaround? Specifically I wanted to override a property setter. |
"No attribute" along with "Untyped decorator" error.
Running mypy with
Line 28 happens to be the |
+ workaround a mypy bug: python/mypy#1465
+ workaround a mypy bug: python/mypy#1465
Co-authored-by: Martin Yeo <40734014+trexfeathers@users.noreply.github.com>
* Enable type hint checking * Add whatsnew entry * Add class variable annotation * Update line numbers in doctests * Implement suggestions from code review * Update docs/src/whatsnew/latest.rst Co-authored-by: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> * Workaround for python/mypy#1465 Co-authored-by: Martin Yeo <40734014+trexfeathers@users.noreply.github.com> * Also apply workaround for bounds * Add type hint --------- Co-authored-by: Martin Yeo <40734014+trexfeathers@users.noreply.github.com>
See python/mypy#1465 for information on the changes in schedule.py
The following code incorrectly raises an error:
Error:
Commenting out the
_other
method will fix the error.The text was updated successfully, but these errors were encountered: