Skip to content

--disallow-any-generics generates spurious messages #7077

@msullivan

Description

@msullivan

In certain cases, --disallow-any-generics will generate an error message in the file where a type alias is used with the line number at which the type alias is defined.

For example

[case testDisallowAnyGenericsMessages]
# mypy: disallow-any-generics
from a import B
x: B

[file a.py]
from typing import TypeVar, List

T = TypeVar('T')

A = List[T]
B = A

[builtins fixtures/list.pyi]

generates the error main:6: error: Missing type parameters for generic type. main:6 is not a line that appears.

The error here is line 6 of a.py, B = A, though that is not an error in this case because disallow-any-generics is not specified for that file. It is triggered by line 3 of main, but reporting an error there would also be wrong because there is nothing wrong with line 3 of main, just with the definition of B. (And there is nothing that can be fixed at that call site, because B is not generic!).

I'm marking this as high priority because disallow-any-generics is a super important option that we I think we should make a default once it is fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions