Skip to content
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

mypy reports the wrong line number for decorator issues #18391

Closed
A5rocks opened this issue Dec 31, 2024 · 0 comments · Fixed by #18392
Closed

mypy reports the wrong line number for decorator issues #18391

A5rocks opened this issue Dec 31, 2024 · 0 comments · Fixed by #18392
Labels
bug mypy got something wrong

Comments

@A5rocks
Copy link
Contributor

A5rocks commented Dec 31, 2024

Bug Report

If a decorator fails to apply, then the error gets noted as the start of the decorator chain.

I expected to find an issue already made about this, but I found nothing. I would not be surprised if this is a duplicate though.

To Reproduce

from collections.abc import Callable

def faulty(c: Callable[[int], None]) -> Callable[[tuple[int, int]], None]:
    return lambda x: None
    
@faulty  # 2 errors reported here
@faulty
def f(x: str) -> None:
    return None

Interestingly, if faulty returns Callable[[str], None] this only reports 1 error. I assume this is an artifact of error deduplication.

Expected Behavior

Different line numbers.

Actual Behavior

Same line numbers.

Your Environment

Checked on mypy playground.

  • Mypy version used: v1.14
  • Mypy command-line flags: strict
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.12
@A5rocks A5rocks added the bug mypy got something wrong label Dec 31, 2024
hauntsaninja added a commit to hauntsaninja/mypy that referenced this issue Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant