Skip to content

Incorrect number of type arguments causes internal error #996

Closed
@bcdarwin

Description

@bcdarwin
from typing import TypeVar

T = TypeVar('T')

class C(object):  # forgot to add type params here
    def __init__(self, t : T) -> None:
        self.t   = t

c = C(t = 3)  # type: C[int]  # this will crash

causes:

Traceback (most recent call last):
    ...
    cb = infer_constraints(mapped.args[i], instance.args[i],
IndexError: list index out of range

I guess this generalizes #981 and provides an additional example, here with an (accidentally) non-generic type (though the same happens if too few type arguments are supplied). I'm not sure if it overlaps with #300.

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