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

Python 3.9.7 is being unsympathetic #557

Closed
gmuloc opened this issue Feb 7, 2024 · 2 comments
Closed

Python 3.9.7 is being unsympathetic #557

gmuloc opened this issue Feb 7, 2024 · 2 comments
Assignees

Comments

@gmuloc
Copy link
Collaborator

gmuloc commented Feb 7, 2024

Tested for anta 0.12.0 and 0.10.0

The error is reproducible in Python 3.9.7 - not present in python 3.9.13.
not root caused yet.

probably need to narrow down the list of versions.

anta --help                                                                                                                                                                 3.9.13    14:46:37 
Traceback (most recent call last):
  File "/Users/guillaumemulocher/py39/venv/bin/anta", line 5, in <module>
    from anta.cli import cli
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/anta/cli/__init__.py", line 17, in <module>
    from anta.cli.check import check as check_command
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/anta/cli/check/__init__.py", line 9, in <module>
    from anta.cli.check import commands
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/anta/cli/check/commands.py", line 15, in <module>
    from anta.catalog import AntaCatalog
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/anta/catalog.py", line 21, in <module>
    from anta.models import AntaTest
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/anta/models.py", line 58, in <module>
    class AntaTemplate(BaseModel):
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 183, in __new__
    set_model_fields(cls, bases, config_wrapper, types_namespace)
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 418, in set_model_fields
    fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/pydantic/_internal/_fields.py", line 99, in collect_model_fields
    type_hints = get_cls_type_hints_lenient(cls, types_namespace)
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 212, in get_cls_type_hints_lenient
    hints[name] = eval_type_lenient(value, globalns, localns)
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 224, in eval_type_lenient
    return typing._eval_type(value, globalns, localns)  # type: ignore
  File "/Users/guillaumemulocher/.pyenv/versions/3.9.7/lib/python3.9/typing.py", line 290, in _eval_type
    return t._evaluate(globalns, localns, recursive_guard)
  File "/Users/guillaumemulocher/.pyenv/versions/3.9.7/lib/python3.9/typing.py", line 551, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
  File "/Users/guillaumemulocher/py39/venv/lib/python3.9/site-packages/pydantic/types.py", line 211, in conint
    annotated_types.Interval(gt=gt, ge=ge, lt=lt, le=le),
TypeError: Interval() takes no arguments

proposed solutions:

  • try / catch around the failing import(s) for pydantic conint and state that we don't support specific python versions that we need to check.
  • remove conint and use Field (and check it works in 3.9.7) - conint will be deprecated in pydantic 3.0.0 anyway
@carl-baillargeon
Copy link
Contributor

constr is also impacted by this.

Traceback (most recent call last):
  File "/home/carlbaillargeon/.pyenv/versions/.anta-test/bin/anta", line 5, in <module>
    from anta.cli import cli
  File "/home/carlbaillargeon/git_projects/anta/anta/cli/__init__.py", line 17, in <module>
    from anta.cli.check import check as check_command
  File "/home/carlbaillargeon/git_projects/anta/anta/cli/check/__init__.py", line 9, in <module>
    from anta.cli.check import commands
  File "/home/carlbaillargeon/git_projects/anta/anta/cli/check/commands.py", line 17, in <module>
    from anta.cli.utils import catalog_options
  File "/home/carlbaillargeon/git_projects/anta/anta/cli/utils.py", line 20, in <module>
    from anta.inventory import AntaInventory
  File "/home/carlbaillargeon/git_projects/anta/anta/inventory/__init__.py", line 21, in <module>
    from anta.inventory.models import AntaInventoryInput
  File "/home/carlbaillargeon/git_projects/anta/anta/inventory/models.py", line 21, in <module>
    class AntaInventoryHost(BaseModel):
  File "/home/carlbaillargeon/.pyenv/versions/3.9.7/envs/.anta-test/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 178, in __new__
    set_model_fields(cls, bases, config_wrapper, types_namespace)
  File "/home/carlbaillargeon/.pyenv/versions/3.9.7/envs/.anta-test/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 452, in set_model_fields
    fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
  File "/home/carlbaillargeon/.pyenv/versions/3.9.7/envs/.anta-test/lib/python3.9/site-packages/pydantic/_internal/_fields.py", line 122, in collect_model_fields
    type_hints = get_cls_type_hints_lenient(cls, types_namespace)
  File "/home/carlbaillargeon/.pyenv/versions/3.9.7/envs/.anta-test/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 212, in get_cls_type_hints_lenient
    hints[name] = eval_type_lenient(value, globalns, localns)
  File "/home/carlbaillargeon/.pyenv/versions/3.9.7/envs/.anta-test/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 224, in eval_type_lenient
    return eval_type_backport(value, globalns, localns)
  File "/home/carlbaillargeon/.pyenv/versions/3.9.7/envs/.anta-test/lib/python3.9/site-packages/pydantic/_internal/_typing_extra.py", line 240, in eval_type_backport
    return typing._eval_type(  # type: ignore
  File "/home/carlbaillargeon/.pyenv/versions/3.9.7/lib/python3.9/typing.py", line 290, in _eval_type
    return t._evaluate(globalns, localns, recursive_guard)
  File "/home/carlbaillargeon/.pyenv/versions/3.9.7/lib/python3.9/typing.py", line 551, in _evaluate
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
  File "/home/carlbaillargeon/.pyenv/versions/3.9.7/envs/.anta-test/lib/python3.9/site-packages/pydantic/types.py", line 785, in constr
    StringConstraints(
TypeError: StringConstraints() takes no arguments

@carl-baillargeon
Copy link
Contributor

Resolved in #476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants