Skip to content

StrEnum fails to compile with mypyc #1059

@dzakarov

Description

@dzakarov
import enum

class Test (enum.StrEnum):
    A: enum.auto = enum.auto()

print (Test.A)

Expected result:
Mypyc compiles StrEnum related code

Actual result:
Mypyc fails to compile.

mypyc test.py
running build_ext
building 'test' extension
gcc -fno-strict-overflow -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -fcf-protection -fexceptions -fcf-protection -fexceptions -fcf-protection -fexceptions -fPIC -I/home/dz/tmp/test/.venv/lib64/python3.12/site-packages/mypyc/lib-rt -I/home/dz/tmp/test/.venv/include -I/usr/include/python3.12 -c build/__native.c -o build/temp.linux-x86_64-cpython-312/build/__native.o -O3 -g1 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-ignored-optimization-argument -Wno-cpp
build/__native.c: In function ‘CPyDef___top_level__’:
build/__native.c:193:17: error: ‘CPyModule_typing’ undeclared (first use in this function); did you mean ‘PyModule_Type’?
  193 |     cpy_r_r21 = CPyModule_typing;
      |                 ^~~~~~~~~~~~~~~~
      |                 PyModule_Type
build/__native.c:193:17: note: each undeclared identifier is reported only once for each function it appears in
build/__native.c:383:17: error: ‘CPyStatic_Test___A’ undeclared (first use in this function)
  383 |     cpy_r_r90 = CPyStatic_Test___A;
      |                 ^~~~~~~~~~~~~~~~~~
At top level:
cc1: note: unrecognized command-line option ‘-Wno-ignored-optimization-argument’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-unused-command-line-argument’ may have been intended to silence earlier diagnostics
error: command '/usr/bin/gcc' failed with exit code 1

Version info:

python -V
Python 3.12.4
mypy -V
mypy 1.11.1 (compiled: yes)
mypyc -V
mypy 1.11.1 (compiled: yes)

mypy does not show any errors;

mypy test.py
Success: no issues found in 1 source file

python runs without errors:

python test.py
a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions