Skip to content

Bug when type annotation has a type union parameter #25

@KrisJordan

Description

@KrisJordan

To reproduce:

def union(x: int | float) -> None:
    print(x)

or

def union(x: int | None) -> None:
    print(x)

Resulting dump:

AttributeError: 'types.UnionType' object has no attribute '__name__'. Did you mean: '__ne__'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/lib/python3.12/runpy.py", line 198, in _run_module_as_main

return _run_code(code, main_globals, None,

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/usr/local/lib/python3.12/runpy.py", line 88, in _run_code

exec(code, run_globals)

File "/home/vscode/.local/lib/python3.12/site-packages/trailhead/wrappers/repl.py", line 202, in <module>

for local in stack_frame.frame.f_locals:

RuntimeError: dictionary changed size during iteration

Need a conditional check for UnionType to disambiguate and likely some logic client side to handle a union.

Metadata

Metadata

Assignees

Labels

HIPRIbugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions