allow_redefinition ignored for functions
Open
Nobody has claimed this yet.
feature
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Mypy complains with error: Name "step_impl" already defined on line 13 error for functions, although allow_redefinition is set to True.
To Reproduce
- Add mypy.ini configuration (listed below)
- Add behave tests; for example:
@given("I am on the main page")
def step_impl(context):
pass
@when("I type login and password")
def step_impl(context):
pass
@then("I am logged in")
def step_impl(context):
pass
- Run mypy
Expected Behavior
Mypy checks pass because allow_redefinition is set to True.
Actual Behavior
Mypy fails with
error: Name "step_impl" already defined on line 13
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files):
[mypy]
python_version = 3.6
allow_redefinition = True
ignore_missing_imports = True
check_untyped_defs = False
- Python version used: 3.6
- Operating system and version: Ubuntu 20.04.2
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 reproducing the reported error with the shown mypy.ini configuration and behave-style repeated function definitions. Then trace mypy's handling of function redefinitions and add a regression test; done means allow_redefinition suppresses this diagnostic while unrelated duplicate-definition errors remain reported.
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
- 38/100