property fail on fget, fset
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Please provide more information to help us understand the issue:
- Are you reporting a bug, or opening a feature request?
Bug - Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
class A():
@property
def a(self) -> float:
return 0.5
class B():
@property
def a(self) -> float:
return 1.5
class C(A, B):
is_a:bool = True
@property
def a(self) -> float:
if self.is_a:
return A.a.fget(self)
else:
return B.a.fget(self)
if __name__ == '__main__':
c = C()
assert c.a ==0.5
c.is_a = False
assert c.a == 1.5
- What is the actual behavior/output?
warning: Returning Any from function declared to return "float"
error: "Callable[[A], float]" has no attribute "fget"
warning: Returning Any from function declared to return "float"
error: "Callable[[B], float]" has no attribute "fget"
-
What is the behavior/output you expect?
mypy should pass -
What are the versions of mypy and Python you are using?
mypy 0.650
Python 3.6.5Do you see the same issue after installing mypy from Git master?
Yes -
What are the mypy flags you are using? (For example --strict-optional)
no flags. -
If mypy crashed with a traceback, please paste
the full traceback below.
(You can freely edit this text, please remove all the lines
you believe are unnecessary.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running mypy on the minimal reproduction in the issue and compare its handling of property access through A.a.fget and B.a.fget. Trace the type-checking path for property descriptors and callable attributes; done means the example passes with the expected float return types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100