Skip to content

dmypy suggest gives wrong type (datetime vs datetime module) #18935

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 17, 2025 · 1 comment · May be fixed by #18937
Open

dmypy suggest gives wrong type (datetime vs datetime module) #18935

asottile-sentry opened this issue Apr 17, 2025 · 1 comment · May be fixed by #18937
Assignees
Labels
bug mypy got something wrong topic-daemon dmypy

Comments

@asottile-sentry
Copy link

Bug Report

the suggestion from dmypy recommends datetime when it should suggest datetime.datetime

To Reproduce

import datetime

def f(x):
    print(x.isoformat())

f(datetime.datetime.now())
[mypy]
check_untyped_defs = true

Expected Behavior

$ dmypy run .
...
$ dmypy suggest t.f
(t:datetime.datetime) -> None

Actual Behavior

$ dmypy run .
...
$ dmypy suggest t.f
(t.datetime) -> None

Your Environment

  • Mypy version used: 1.15.0
  • Mypy command-line flags: see above
  • Mypy configuration options from mypy.ini (and other config files): see above
  • Python version used: 3.13.1
@asottile-sentry asottile-sentry added the bug mypy got something wrong label Apr 17, 2025
@brianschubert brianschubert self-assigned this Apr 17, 2025
@asottile-sentry
Copy link
Author

I believe the bug is here:

if tree and parts[0] in tree.names:
-- it checks for the presence of the name but not whether it's the same thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-daemon dmypy
Projects
None yet
2 participants