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

Bug: TypeError: Unable to evaluate type annotation "Optional[constr(regex='password')]". #308

Closed
sternakt opened this issue Oct 3, 2024 · 0 comments · Fixed by #313
Closed
Assignees
Labels
bug Something isn't working

Comments

@sternakt
Copy link
Collaborator

sternakt commented Oct 3, 2024

Describe the bug
When creating a client from openapi_spec.json, the code breaks with:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/Documents/Airt Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:279, in eval_type_backport(value, globalns, localns, type_params)
    [278](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:278) try:
--> [279](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:279)     return _eval_type_backport(value, globalns, localns, type_params)
    [280](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:280) except TypeError as e:

File ~/Documents/Airt Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:303, in _eval_type_backport(value, globalns, localns, type_params)
    [302](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:302) try:
--> [303](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:303)     return _eval_type(value, globalns, localns, type_params)
    [304](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:304) except TypeError as e:

File ~/Documents/Airt Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:332, in _eval_type(value, globalns, localns, type_params)
    [331](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:331) else:
--> [332](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:332)     return typing._eval_type(  # type: ignore
    [333](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:333)         value, globalns, localns
    [334](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:334)     )

File /opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:327, in _eval_type(t, globalns, localns, recursive_guard)
    [326](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:326) if isinstance(t, ForwardRef):
--> [327](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:327)     return t._evaluate(globalns, localns, recursive_guard)
    [328](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:328) if isinstance(t, (_GenericAlias, GenericAlias, types.UnionType)):

File /opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:694, in ForwardRef._evaluate(self, globalns, localns, recursive_guard)
    [690](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:690)     globalns = getattr(
    [691](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:691)         sys.modules.get(self.__forward_module__, None), '__dict__', globalns
    [692](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:692)     )
    [693](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:693) type_ = _type_check(
--> [694](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:694)     eval(self.__forward_code__, globalns, localns),
    [695](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:695)     "Forward references must evaluate to types.",
    [696](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:696)     is_argument=self.__forward_is_argument__,
    [697](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:697)     allow_special_forms=self.__forward_is_class__,
    [698](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:698) )
    [699](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:699) self.__forward_value__ = _eval_type(
    [700](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:700)     type_, globalns, localns, recursive_guard | {self.__forward_arg__}
    [701](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py:701) )

File <string>:1

TypeError: constr() got an unexpected keyword argument 'regex'

The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)
Cell In[2], [line 1](vscode-notebook-cell:?execution_count=2&line=1)
----> [1](vscode-notebook-cell:?execution_count=2&line=1) OpenAPI.create(openapi_json=Path("openapi_spec.json").read_text(), client_source_path="fastagency/client")

File ~/Documents/Airt Projects/fastagency/fastagency/api/openapi/client.py:315, in OpenAPI.create(cls, openapi_json, openapi_url, client_source_path)
    [313](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency/fastagency/api/openapi/client.py:313) try:
    [314](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency/fastagency/api/openapi/client.py:314)     sys.path.append(str(td))
--> [315](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency/fastagency/api/openapi/client.py:315)     main = importlib.import_module(main_name, package=td.name)  # nosemgrep
    [316](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency/fastagency/api/openapi/client.py:316) finally:
    [317](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency/fastagency/api/openapi/client.py:317)     sys.path.remove(str(td))

File /opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
    [124](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py:124)             break
    [125](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py:125)         level += 1
--> [126](https://file+.vscode-resource.vscode-cdn.net/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py:126) return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1050, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1027, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1006, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:688, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:883, in exec_module(self, module)

File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)

File ~/Documents/Airt Projects/fastagency-prototyping/fastagency/client/main_client.py:14
     [11](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:11) from fastagency.api.openapi.security import OAuth2PasswordBearer
     [12](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:12) from starlette.requests import Request
---> [14](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:14) from models_client import HTTPValidationError
     [16](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:16) app = OpenAPI(
     [17](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:17)     title='OAuth2',
     [18](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:18)     version='0.1.0',
   (...)
     [21](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:21)     ],
     [22](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:22) )
     [25](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:25) @app.post(
     [26](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:26)     '/low',
     [27](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:27)     response_model=Dict[str, str],
   (...)
     [32](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:32) )
     [33](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/main_client.py:33) def post_oauth_low_post(message: str) -> Union[Dict[str, str], HTTPValidationError]:

File ~/Documents/Airt Projects/fastagency-prototyping/fastagency/client/models_client.py:12
      [7](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/models_client.py:7) from typing import List, Optional, Union
      [9](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/models_client.py:9) from pydantic import BaseModel, Field, constr
---> [12](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/models_client.py:12) class BodyLoginTokenPost(BaseModel):
     [13](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/models_client.py:13)     grant_type: Optional[constr(regex=r'password')] = Field(None, title='Grant Type')
     [14](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/fastagency/client/models_client.py:14)     username: str = Field(..., title='Username')

File ~/Documents/Airt Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:219, in ModelMetaclass.__new__(mcs, cls_name, bases, namespace, __pydantic_generic_metadata__, __pydantic_reset_parent_namespace__, _create_model_module, **kwargs)
    [216](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:216)     parent_namespace = unpack_lenient_weakvaluedict(parent_namespace)
    [218](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:218) types_namespace = merge_cls_and_parent_ns(cls, parent_namespace)
--> [219](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:219) set_model_fields(cls, bases, config_wrapper, types_namespace)
    [221](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:221) if config_wrapper.frozen and '__hash__' not in namespace:
    [222](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:222)     set_default_hash_func(cls, bases)

File ~/Documents/Airt Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:512, in set_model_fields(cls, bases, config_wrapper, types_namespace)
    [503](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:503) """Collect and set `cls.model_fields` and `cls.__class_vars__`.
    [504](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:504) 
    [505](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:505) Args:
   (...)
    [509](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:509)     types_namespace: Optional extra namespace to look for types in.
    [510](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:510) """
    [511](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:511) typevars_map = get_model_typevars_map(cls)
--> [512](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:512) fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
    [514](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:514) cls.model_fields = fields
    [515](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py:515) cls.__class_vars__.update(class_vars)

File ~/Documents/Airt Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_fields.py:105, in collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map)
    [102](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_fields.py:102) BaseModel = import_cached_base_model()
    [103](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_fields.py:103) FieldInfo_ = import_cached_field_info()
--> [105](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_fields.py:105) type_hints = get_cls_type_hints_lenient(cls, types_namespace)
    [107](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_fields.py:107) # https://docs.python.org/3/howto/annotations.html#accessing-the-annotations-dict-of-an-object-in-python-3-9-and-older
    [108](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_fields.py:108) # annotations is only used for finding fields in parent classes
    [109](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_fields.py:109) annotations = cls.__dict__.get('__annotations__', {})

File ~/Documents/Airt Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:245, in get_cls_type_hints_lenient(obj, globalns, mro)
    [243](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:243)     if ann is not None and ann is not GetSetDescriptorType:
    [244](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:244)         for name, value in ann.items():
--> [245](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:245)             hints[name] = eval_type_lenient(value, globalns, localns)
    [246](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:246) return hints

File ~/Documents/Airt Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:257, in eval_type_lenient(value, globalns, localns)
    [254](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:254)     value = _make_forward_ref(value, is_argument=False, is_class=True)
    [256](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:256) try:
--> [257](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:257)     return eval_type_backport(value, globalns, localns)
    [258](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:258) except NameError:
    [259](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:259)     # the point of this function is to be tolerant to this case
    [260](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:260)     return value

File ~/Documents/Airt Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:293, in eval_type_backport(value, globalns, localns, type_params)
    [291](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:291)     raise
    [292](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:292) else:
--> [293](https://file+.vscode-resource.vscode-cdn.net/Users/tvrtko/Documents/Airt%20Projects/fastagency-prototyping/~/Documents/Airt%20Projects/fastagency-prototyping/.venv/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py:293)     raise TypeError(message) from e

TypeError: Unable to evaluate type annotation "Optional[constr(regex='password')]".

How to reproduce

from pathlib import Path

from fastagency.api.openapi import OpenAPI

OpenAPI.create(openapi_json=Path("openapi_spec.json").read_text(), client_source_path="fastagency/client")
@sternakt sternakt added the bug Something isn't working label Oct 3, 2024
@sternakt sternakt self-assigned this Oct 3, 2024
@sternakt sternakt linked a pull request Oct 4, 2024 that will close this issue
10 tasks
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

Successfully merging a pull request may close this issue.

1 participant