Skip to content

Mypy crashes on abstract class with generic type parameter #19946

@bmmcq

Description

@bmmcq

Crash Report

crash at the first line of :

class JobWeaver[T](abc.ABC):
    @abc.abstractmethod
    def data_type(self) -> type[T] | None: 
        ...
    @abc.abstractmethod
    def map[OT](self, args) -> "JobWeaver[OT]"
        ...

It only defines a totally abstract class with a generic type parameter.

Traceback

src/nagas_api/weaver.py:7: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.18.1
Traceback (most recent call last):
  File "mypy/semanal.py", line 7350, in accept
  File "mypy/nodes.py", line 1440, in accept
  File "mypy/semanal.py", line 1775, in visit_class_def
  File "mypy/semanal.py", line 1916, in analyze_class
  File "mypy/semanal.py", line 2222, in clean_up_bases_and_infer_type_variables
AssertionError: 
src/nagas_api/weaver.py:7: : note: use --pdb to drop into pdb

Your Environment

  • Mypy version used: 1.18.1

  • Mypy command-line flags:
    uv run --active --group test mypy ./src --show-traceback --config-file ../pyproject.toml

  • Mypy configuration options from mypy.ini (and other config files):

[tool.mypy]
ignore_missing_imports = true
check_untyped_defs = true
follow_imports = "silent"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
exclude = [
    '^test\.',
    'tests/'
]
  • Python version used: 3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashpendingIssues that may be closedtopic-pep-695Issues related to PEP 695 syntax

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions