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

Issue using typing-extensions > 4.5.0 #162

Open
ondrej-ivanko opened this issue Aug 8, 2024 · 2 comments
Open

Issue using typing-extensions > 4.5.0 #162

ondrej-ivanko opened this issue Aug 8, 2024 · 2 comments

Comments

@ondrej-ivanko
Copy link

ondrej-ivanko commented Aug 8, 2024

Hi,

when I was trying you package with one of the newest versions of FastaAPI which depends on typing-extension >=4.8.0, I ran into a typing error in your code. It applies I believe only to python version less than 3.10. There were changes to Literal which you're using in cases of some of your pydantic Models

I have to use python 3.9 along with Pydantic 1.10.x for dependency purposes. Our company cannot raise the versions of some libraries without proper testing. Is it possible on you side to create new 0.6.x patch version, which uses typing which would work on Python 3.9.

I added links to the issue in Pydantic.
pydantic/pydantic#5824
python/typing_extensions@fb37b2e
pydantic/pydantic#5821 (comment)
pydantic/pydantic#545 (comment)

for better location of error I added logs. It happens already when trying to import the Model Point

rypmaps-gateway-1  |   File "/varistar/./app/schemas/response_schemas.py", line 3, in <module>
rypmaps-gateway-1  |     from geojson_pydantic import Feature, Point
rypmaps-gateway-1  |   File "/usr/local/lib/python3.9/site-packages/geojson_pydantic/__init__.py", line 3, in <module>
rypmaps-gateway-1  |     from .features import Feature, FeatureCollection  # noqa
rypmaps-gateway-1  |   File "/usr/local/lib/python3.9/site-packages/geojson_pydantic/features.py", line 9, in <module>
rypmaps-gateway-1  |     from geojson_pydantic.geometries import Geometry, GeometryCollection
rypmaps-gateway-1  |   File "/usr/local/lib/python3.9/site-packages/geojson_pydantic/geometries.py", line 114, in <module>
rypmaps-gateway-1  |     class Point(_GeometryBase):
rypmaps-gateway-1  |   File "pydantic/main.py", line 204, in pydantic.main.ModelMetaclass.__new__
rypmaps-gateway-1  |   File "pydantic/fields.py", line 488, in pydantic.fields.ModelField.infer
rypmaps-gateway-1  |   File "pydantic/fields.py", line 419, in pydantic.fields.ModelField.__init__
rypmaps-gateway-1  |   File "pydantic/fields.py", line 534, in pydantic.fields.ModelField.prepare
rypmaps-gateway-1  |   File "pydantic/fields.py", line 638, in pydantic.fields.ModelField._type_analysis
rypmaps-gateway-1  |   File "/usr/local/lib/python3.9/typing.py", line 852, in __subclasscheck__
rypmaps-gateway-1  |     return issubclass(cls, self.__origin__)
rypmaps-gateway-1  | TypeError: issubclass() arg 1 must be a class

code:

from geojson_pydantic import FeatureCollection, Point

Thank you for your help.

@ondrej-ivanko
Copy link
Author

A workaround is using no_type_check decorator from typing

from typing import no_type_check

from geojson_pydantic import FeatureCollection, Point
no_type_check(Point)

@vincentsarago
Copy link
Member

@ondrej-ivanko I guess you're using geojson-pydantic 0.6

I'll be happy to review any PR patching 0.6 with a fix 🙏

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

No branches or pull requests

2 participants