enigmatic "name already defined" error
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.
There are four pieces of code:
def func(x: int) -> int:
return x + 1
def func(x):
return x
def func(x):
return x
def func(x: int) -> int:
return x + 1
from test import func
def func(x: int) -> int:
return x + 1
def func(x: int) -> int:
return x + 1
from test import func
Whenever test is used as a module, test.py contains
def func(x):
return x
- What is the actual behavior/output?
The first three examples emits "Name 'func' already defined" error, but not the last
- What is the behavior/output you expect?
All four should emit this error.
- What are the versions of mypy and Python you are using?
mypy 0.720+dev.dc6da54f50d5443fe46308046719043eba03c84d (master at the time of bug report)
Python 3.7.3
- What are the mypy flags you are using? (For example --strict-optional)
None.
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 the four inline reproductions with the reported mypy version, using test.py for the imported function. Compare the diagnostics for each import and redefinition order. Done means the behavior is consistent with the report's expectation that all four cases emit the duplicate-definition error.
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
- 35/100