Skip to content

Bug Report: Inconsistent Return Type Checking Between Python 3.9.21 and 3.9.23 with Mypy​ #19680

@WSYAH

Description

@WSYAH

Problem Description​

The same codebase produces ​different type-checking results​ under ​Python 3.9.21​ (detects an error) vs ​Python 3.9.23​ (no error), using the ​same Mypy version (1.6.0 and 1.17.1, tested both)​​ and ​identical Mypy configuration.

This inconsistency breaks team collaboration, as developers using different minor Python 3.9.x versions (e.g., 3.9.21 vs 3.9.23) get conflicting type-check results for the same code.

Reproduction Steps​

​ Environment 1 (Error Detected)​:

Python Version: 3.9.21
Mypy Command: mypy .
Mypy Config (pyproject.toml):

[tool.mypy]
ignore_missing_imports = true 
disallow_untyped_defs = true
explicit_package_bases = true
mypy_path = './'             
exclude = [
    '^script/.*',
    '.*setup.py$',
]

​Environment 2 (No Error)​:

Python Version: 3.9.23
Mypy Command: mypy .
Same Mypy Config and Version (1.6.0 / 1.17.1).
Result: ​No errors reported​ for the same file/code.

Here is the Mypy check results screenshot for two different Python versions
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions