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

TypeError: typing.ClassVar[typing.Type[fastapi_pagination.bases.AbstractParams]] is not valid as type argument #228

Closed
afanasevps opened this issue Nov 10, 2021 · 3 comments · Fixed by #229
Labels
bug Something isn't working

Comments

@afanasevps
Copy link

does work with python3.9.8

268  File "/builds/app/app.py", line 5, in <module>
268    from fastapi_pagination import add_pagination
269  File "/usr/local/lib/python3.9/site-packages/fastapi_pagination/__init__.py", line 1, in <module>
270    from .api import (
271  File "/usr/local/lib/python3.9/site-packages/fastapi_pagination/api.py", line 12, in <module>
272    from .bases import AbstractPage, AbstractParams
273  File "/usr/local/lib/python3.9/site-packages/fastapi_pagination/bases.py", line 54, in <module>
274    class AbstractPage(GenericModel, Generic[T], ABC):
275  File "pydantic/main.py", line 282, in pydantic.main.ModelMetaclass.__new__
276  File "pydantic/typing.py", line 287, in pydantic.typing.resolve_annotations
277    For use of globalns and localns see the docstring for get_type_hints().
278  File "/usr/local/lib/python3.9/typing.py", line 292, in _eval_type
279    return t._evaluate(globalns, localns, recursive_guard)
280  File "/usr/local/lib/python3.9/typing.py", line 553, in _evaluate
281    type_ = _type_check(
282  File "/usr/local/lib/python3.9/typing.py", line 158, in _type_check
283    raise TypeError(f"{arg} is not valid as type argument")
284TypeError: typing.ClassVar[typing.Type[fastapi_pagination.bases.AbstractParams]] is not valid as type argument 
@uriyyo uriyyo added the bug Something isn't working label Nov 10, 2021
@rushilsrivastava
Copy link
Contributor

This still seems to happen on Python 3.9.9 - I'm guessing this is a problem with Pydantic, and not this library though.

@uriyyo
Copy link
Owner

uriyyo commented Dec 2, 2021

Yup, it's a pydantic issue.

But this issue should not be present anymore because fastapi-pagination version 0.9.1 contains a workaround.

@rushilsrivastava
Copy link
Contributor

rushilsrivastava commented Dec 7, 2021

Yup, it's a pydantic issue.

But this issue should not be present anymore because fastapi-pagination version 0.9.1 contains a workaround.

Maybe I am doing completely wrong here - using the latest version, all my pytest fail with the error above, but the code will run. The only way to fix the pytest errors is by using the latest master version of pydantic, but that introduces other breaking changes in my code and breaks while running.

I'm using a custom page setup (basic page with an added total pages parameter), not really sure what I'm missing here.

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.

3 participants