Repository navigation
Closed
Labels
bugSomething isn't working
Description
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.
Activity
pawamoy commentedon Feb 4, 2025
Hi @davidmezzetti, thank you for the report, and for the kind words 💓 ! Could you tell me what version of Pydantic you have installed?
davidmezzetti commentedon Feb 4, 2025
I appreciate the rapid response. Here is what I have:
pawamoy commentedon Feb 4, 2025
Thank you! OK I had
eval-type-backportinstalled locally so didn't catch this behavior. Let me add this dependency for Python 3.9 🙂 EDIT: hmm, actually no, it wouldn't be of any help to haveeval-type-backportif we don't havepydanticinstalled in the first place. I'll instead add a check in order to deactivate Pydantic use if eval-type-backport is not available on Python 3.9.davidmezzetti commentedon Feb 4, 2025
Sounds good, whatever is easier for you and makes sense for the project. I appreciate the quick dialogue.
fix: Deactivate Pydantic validation on Python 3.9 is `eval-type-backp…
pawamoy commentedon Feb 4, 2025
v1.14.4 released, thanks again!
davidmezzetti commentedon Feb 4, 2025
Wow, thank you for the rapid response. Now that's service!
davidmezzetti commentedon Feb 4, 2025
And I'll confirm the issue is fixed for my use case!
pawamoy commentedon Feb 4, 2025
Awesome, thanks for confirming 🙏
fix: Deactivate Pydantic validation on Python 3.9 is `eval-type-backp…