python / python/mypy

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

Open
#18,763 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-daemon
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the nested class example under Python 3.11 and compare the results from dmypy and mypy. The issue is done when dmypy no longer reports a spurious missing-annotation error where mypy does not, including across repeated daemon runs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.