8000 internal error using Enum and __new__ · Issue #1081 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content
internal error using Enum and __new__ #1081
Closed
@bcdarwin

Description

@bcdarwin

Making a list of types looks weird, but this was originally used to construct a typing.NamedTuple.

import typing
from typing import Tuple, Callable, Any, List
from enum import Enum

class MyEnum(Enum):
    def __new__(cls): pass

def F(fields: List[Callable[[Any], Any]]): pass

class SomeEnum(MyEnum):
    x = 1

F([SomeEnum])

produces:

Traceback (most recent call last):
  ...
  File "/home/bdarwin/.local/lib/python3.5/site-packages/mypy/types.py", line 346, in accept
    return visitor.visit_callable_type(self)
  File "/home/bdarwin/.local/lib/python3.5/site-packages/mypy/constraints.py", line 231, in visit_callable_type
    template.arg_types[i], cactual.arg_types[i],
IndexError: list index out of range

*** INTERNAL ERROR ***

foo.py:13: error: Internal error -- please report a bug at https://github.com/JukkaL/mypy/issues
The program exited via sys.exit(). Exit status: 1

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

      0