Skip to content

bug: TypeError: Unable to evaluate type annotation with 1.14.x #241

Closed
@davidmezzetti

Description

@davidmezzetti

Hello,

First off, thank you for your efforts in open source. I've been a long time user of this library with txtai and have never had issues. So while I'm reporting an issue now, just wanted to first say I appreciate all the hard work.

With 1.14.x, I'm getting a doc build error as follows with Python 3.9.

  File "python3.9/site-packages/mkdocstrings_handlers/python/__init__.py", line 3, in <module>
    from mkdocstrings_handlers.python.handler import get_handler
  File "python3.9/site-packages/mkdocstrings_handlers/python/handler.py", line 30, in <module>
    from mkdocstrings_handlers.python.config import PythonConfig, PythonOptions
  File "python3.9/site-packages/mkdocstrings_handlers/python/config.py", line 254, in <module>
    class AutoStyleOptions:
  File "python3.9/site-packages/pydantic/dataclasses.py", line 276, in create_dataclass
    _pydantic_dataclasses.complete_dataclass(cls, config_wrapper, raise_errors=False)
  File "python3.9/site-packages/pydantic/_internal/_dataclasses.py", line 128, in complete_dataclass
    set_dataclass_fields(cls, ns_resolver, config_wrapper=config_wrapper)
  File "python3.9/site-packages/pydantic/_internal/_dataclasses.py", line 78, in set_dataclass_fields
    fields = collect_dataclass_fields(
  File "python3.9/site-packages/pydantic/_internal/_fields.py", line 322, in collect_dataclass_fields
    ann_type, _ = _typing_extra.try_eval_type(dataclass_field.type, globalns, localns)
  File "python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 558, in try_eval_type
    return eval_type_backport(value, globalns, localns), True
  File "python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 609, in eval_type_backport
    return _eval_type_backport(value, globalns, localns, type_params)
  File "python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 641, in _eval_type_backport
    raise TypeError(
TypeError: Unable to evaluate type annotation "Annotated[str | None, Field(group='docstrings', parent='docstring_options', description='The default docstring style to use if no other style is detected.')]". If you are making use of the new typing syntax (unions using `|` since Python 3.10 or builtins subscripting since Python 3.9), you should either replace the use of new syntax with the existing `typing` constructs or install the `eval_type_backport` package.

Installing the eval_type_backport package fixes the issue. But given that it didn't happen before 1.14.x, I wanted to let you know. If this is expected, please feel free to close the issue.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions