Skip to content

dmypy suggest crashes on __new__ with IndexError #18964

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

Open
asottile-sentry opened this issue Apr 24, 2025 · 0 comments · May be fixed by #18966
Open

dmypy suggest crashes on __new__ with IndexError #18964

asottile-sentry opened this issue Apr 24, 2025 · 0 comments · May be fixed by #18966

Comments

@asottile-sentry
Copy link

Bug Report

a crash occurs when requesting suggestions for __new__ with no args and a caller

just a guess at the line since I haven't poked it yet -- I think the problem is here:

for typ in call.arg_types[i - is_method]:
(and that __new__ is not considered is_method = True)

To Reproduce

class C:
    def __new__(cls):
        return cls()

c = C()

Expected Behavior

probably () -> C or () -> Self ?

Actual Behavior

$ dmypy run t.py
Daemon started
Success: no issues found in 1 source file
$ dmypy suggest t.C.__new__
Daemon crashed!
Traceback (most recent call last):
  File "mypy/dmypy_server.py", line 237, in serve
  File "mypy/dmypy_server.py", line 286, in run_command
  File "mypy/dmypy_server.py", line 983, in cmd_suggest
  File "mypy/suggestions.py", line 267, in suggest
  File "mypy/suggestions.py", line 480, in get_suggestion
  File "mypy/suggestions.py", line 404, in get_guesses
  File "mypy/suggestions.py", line 350, in get_args
IndexError: list index out of range

Your Environment

  • Mypy version used: 1.15.0
  • Mypy command-line flags: see above
  • Mypy configuration options from mypy.ini (and other config files): n/a
  • Python version used: 3.13.1
@asottile-sentry asottile-sentry added the bug mypy got something wrong label Apr 24, 2025
@sterliakov sterliakov added crash topic-daemon dmypy and removed bug mypy got something wrong labels Apr 24, 2025
asottile-sentry added a commit to getsentry/sentry that referenced this issue Apr 24, 2025
@sterliakov sterliakov linked a pull request Apr 25, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants