#3816·Nuitka

Generic type in class is not fully scoped

Author: SeepMysteryCreated Mar 12, 2026Updated Sep 29, 2026
Labelsbugfactory

Bug Report

I've discovered the scope issue while using the typing module. Here is a test case. The parameter annotations in #3005 work fine, but if you put it into the runtime scope, an error occurs.

️ Environment

4.1rc3 Commercial: None Python: 3.12.11 (main, Jul 1 2025, 05:29:09) [GCC 12.2.0] Flavor: Unknown Executable: /usr/local/bin/python OS: Linux Arch: x86_64 Distribution: Debian 12 Version C compiler: gcc (gcc 12).

️ To Reproduce

python
class TestClass[T]:
    def method(self):
        print(T)

TestClass().method()

Expected Behavior

On CPython, the code doesn't error out.

Actual Behavior & Output

python
Traceback (most recent call last):
  File "/workspaces/Nuitka/tests/basics/ClassesTest312.py", line 36, in <module>
    TestClass().method()
  File "/workspaces/Nuitka/tests/basics/ClassesTest312.py", line 34, in method
    print(T)
NameError: name 'T' is not defined

↩️ Regression (if applicable)

N/A