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

dmypy gives errors that mypy does not give, also the error makes no sense #18763

Open
johnfn opened this issue Mar 6, 2025 · 2 comments
Open
Labels
bug mypy got something wrong

Comments

@johnfn
Copy link

johnfn commented Mar 6, 2025

Bug Report

When running dmypy I get this error sometimes:

Linting...
Function is missing a type annotation

>>> 78 class ApplicationDataBaseApplicationModel):

This doesn't make sense for two reasons:

  • mypy does not ever error on this line
  • There is no function on this line, let alone an unannotated one

The surrounding code looks like this:

class SomeReturnType:
    ...

def my_function(team_id: int, job_id: int) -> type[SomeReturnType]:
    # do some initial work, set some variables etc

    class ApplicationData(BaseApplicationModel):
        # ... more class properties here

To Reproduce

Can't say exactly because dmypy doesn't always give an error.

Expected Behavior

No error.

Your Environment

  • Mypy version used: v1.15
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): see my previous issues
  • Python version used: 3.11
@johnfn johnfn added the bug mypy got something wrong label Mar 6, 2025
@A5rocks
Copy link
Collaborator

A5rocks commented Mar 7, 2025

Notably you're using the pydantic plugin, which I suspect is causing some issue. It's likely creating an __init__ or something marked as the same location as the class, which mypy then checks.

Not sure why mypy vs dmypy differ though.

@johnfn
Copy link
Author

johnfn commented Mar 7, 2025

Thanks, that's a useful tip!

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

No branches or pull requests

2 participants