Type hints and a function returning property
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
I have a function that works correctly.
This function uses a string as an argument and return a property.
But when I add type hints that argument is a string and return is a property, mypy says:
main.py:4: error: "property" used with a non-method
main.py:14: error: Incompatible return value type (got overloaded function, expected "property")'
Found 2 errors in 1 file (checked 1 source file)
To Reproduce
A reproducible playground link
Expected Behavior
I expect that the function has to pass mypy test without errors.
Actual Behavior
main.py:4: error: "property" used with a non-method
main.py:14: error: Incompatible return value type (got overloaded function, expected "property")'
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 0.981
- Mypy command-line flags: no flags
- Mypy configuration options from
mypy.ini(and other config files): default config - Python version used: 3.10
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 with the linked mypy playground reproduction and the shown main.py errors, using mypy 0.981 on Python 3.10 with default settings. Trace how the function's string argument and property return annotation are checked; done means the reproduction runs without the reported errors while preserving the function's behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100