Skip to content
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

Does not make use of typeapi's ability to evaluate future Type hint syntax in Python 3.8 #35

Open
NiklasRosenstein opened this issue Jan 25, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@NiklasRosenstein
Copy link
Owner

Example traceback:

 File "/home/coder/.dotfiles-reconciler/venv/lib/python3.8/site-packages/databind/json/converters.py", line 418, in _get_schema
    return self.convert_to_schema(datatype)
  File "/home/coder/.dotfiles-reconciler/venv/lib/python3.8/site-packages/databind/core/schema.py", line 128, in convert_to_schema
    schema = convert_dataclass_to_schema(hint.type)
  File "/home/coder/.dotfiles-reconciler/venv/lib/python3.8/site-packages/databind/core/schema.py", line 189, in convert_dataclass_to_schema
    annotations = get_annotations(base_type)
  File "/home/coder/.dotfiles-reconciler/venv/lib/python3.8/site-packages/typeapi/utils.py", line 321, in get_annotations
    annotations = _get_type_hints(obj, globalns=globalns, localns=localns)
  File "/usr/lib/python3.8/typing.py", line 1232, in get_type_hints
    value = _eval_type(value, base_globals, localns)
  File "/usr/lib/python3.8/typing.py", line 270, in _eval_type
    return t._evaluate(globalns, localns)
  File "/usr/lib/python3.8/typing.py", line 518, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Seems like we end up evaluating the annotations inside of typeapi.get_annotations() without the future support.

@NiklasRosenstein NiklasRosenstein added the bug Something isn't working label Jan 25, 2023
@NiklasRosenstein NiklasRosenstein self-assigned this Jan 25, 2023
@NiklasRosenstein
Copy link
Owner Author

This might as well be a bug in typeapi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant