podhmo / metashape

0 stars 1 forks source link

TypeError is occured, when the walker run with recursive=True and LiteralType #101

Closed podhmo closed 2 years ago

podhmo commented 3 years ago
from __future__ import annotations
import sys
import typing as t
from metashape.runtime import get_walker

Direction = t.Literal["N", "S", "E", "W"]

class A:
    direction: Direction

for cls in get_walker(sys.modules[__name__], recursive=True, aggressive=True).walk():
    print(cls)

error

Traceback (most recent call last):
  File "01walk/main.py", line 13, in <module>
    for cls in get_walker(sys.modules[__name__], recursive=True, aggressive=True).walk():
  File "VENV/metashape/metashape/runtime.py", line 138, in get_walker
    w._members = list(
  File "VENV/metashape/metashape/runtime.py", line 190, in _mark_recursive
    for _, info, _ in w.walk_fields(m):
  File "VENV/metashape/metashape/analyze/walker.py", line 132, in walk
    for name, field_type, metadata in self.iterate_props(
  File "VENV/metashape/metashape/_access.py", line 101, in iterate_props
    hints = _get_type_hints(typ, localns=getattr(typ, "__dict__", None))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/typing.py", line 1255, in get_type_hints
    raise TypeError('{!r} is not a module, class, method, '
TypeError: typing.Literal['N', 'S', 'E', 'W'] is not a module, class, method, or function.
podhmo commented 2 years ago

fixed