Skip to content

Mypyc KeyError: mypy.nodes.MemberExpr #17794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CoolCat467 opened this issue Sep 20, 2024 · 1 comment
Closed

Mypyc KeyError: mypy.nodes.MemberExpr #17794

CoolCat467 opened this issue Sep 20, 2024 · 1 comment
Labels
bug mypy got something wrong

Comments

@CoolCat467
Copy link

Likely a duplicate of the same issue encountered in #17321, but posting because that issue was closed.

Bug Report

Mypyc seems to encounter an error when handling Literal[<anything>]

To Reproduce

base_io.py

from __future__ import annotations

from enum import Enum
from typing import Literal, TypeAlias


class StructFormat(str, Enum):
    """All possible write/read struct types.

    .. seealso:
        :module:`struct` module documentation.
    """

    BOOL = "?"
    CHAR = "c"
    BYTE = "b"
    UBYTE = "B"
    SHORT = "h"
    USHORT = "H"
    INT = "i"
    UINT = "I"
    LONG = "l"
    ULONG = "L"
    FLOAT = "f"
    DOUBLE = "d"
    HALFFLOAT = "e"
    LONGLONG = "q"
    ULONGLONG = "Q"


INT_FORMATS_TYPE: TypeAlias = Literal[
    StructFormat.BYTE,
    StructFormat.UBYTE,
    StructFormat.SHORT,
    StructFormat.USHORT,
    StructFormat.INT,
    StructFormat.UINT,
    StructFormat.LONG,
    StructFormat.ULONG,
    StructFormat.LONGLONG,
    StructFormat.ULONGLONG,
]

FLOAT_FORMATS_TYPE: TypeAlias = Literal[
    StructFormat.FLOAT,
    StructFormat.DOUBLE,
    StructFormat.HALFFLOAT,
]
mypyc base_io.py

Expected Behavior

No issues

Actual Behavior

Traceback (most recent call last):
base_io.py:32: KeyError: <mypy.nodes.MemberExpr object at 0x7038e01022a0>

Your Environment

  • Mypy version used: mypy 1.11.2 (compiled: yes)
  • Mypy command-line flags: None
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: Python 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] on linux
@CoolCat467
Copy link
Author

Closing in favor of mypyc/mypyc#1064

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant