eseglem / pycql2 Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Working from 8d93545 on Python 3.11, I cannot import the module:
python3.11/typing.py:1551: in __subclasscheck__
return issubclass(cls, self.__origin__)
E TypeError: issubclass() arg 1 must be a class
To reproduce (from a bare venv):
pip install poetry && poetry install && pytest
Output:
-- 8< --
_________________________________________________________ ERROR collecting tests/test_cql2_pydantic.py _________________________________________________________
tests/test_cql2_pydantic.py:1: in <module>
from pycql2.cql2_pydantic import join_list, make_char_literal
pycql2/cql2_pydantic.py:231: in <module>
class ArrayExpression(BaseModel):
pydantic/main.py:222: in pydantic.main.ModelMetaclass.__new__
???
pydantic/fields.py:506: in pydantic.fields.ModelField.infer
???
pydantic/fields.py:436: in pydantic.fields.ModelField.__init__
???
pydantic/fields.py:552: in pydantic.fields.ModelField.prepare
???
pydantic/fields.py:668: in pydantic.fields.ModelField._type_analysis
???
../../.local/share/rtx/installs/python/3.11.2/lib/python3.11/typing.py:1551: in __subclasscheck__
return issubclass(cls, self.__origin__)
E TypeError: issubclass() arg 1 must be a class
____________________________________________________________ ERROR collecting tests/test_pycql2.py _____________________________________________________________
tests/test_pycql2.py:6: in <module>
from pycql2.cql2_pydantic import BooleanExpression
pycql2/cql2_pydantic.py:231: in <module>
class ArrayExpression(BaseModel):
pydantic/main.py:222: in pydantic.main.ModelMetaclass.__new__
???
pydantic/fields.py:506: in pydantic.fields.ModelField.infer
???
pydantic/fields.py:436: in pydantic.fields.ModelField.__init__
???
pydantic/fields.py:552: in pydantic.fields.ModelField.prepare
???
pydantic/fields.py:668: in pydantic.fields.ModelField._type_analysis
???
../../.local/share/rtx/installs/python/3.11.2/lib/python3.11/typing.py:1551: in __subclasscheck__
return issubclass(cls, self.__origin__)
E TypeError: issubclass() arg 1 must be a class
-- 8< --
Currently the only way to determine usage is looking at the tests.
__root__
throughout the models.Currently Accenti and Casei are a bit tricky, where each one has subclasses for CharacterExpression and PatternExpression
Accenti
AccentiCharacterExpression
AccentiPatternExpression
Casei
CaseiCharacterExpression
CaseiPatternExpression
This allows the proper enforcement of types, but generics could be nice to have. The issue is with Pydantic and runtime typing not completely lining up. A lot of messy attempts have been made to get it working but still trying to find a good solution.
There are Hypothesis tests for the Lark grammar, but still need to add them to the Pydantic models.
This requires some custom strategies to ensure the various strings are valid within the grammar. Certain characters are problematic. Can probably do from_regex
and pull them from the grammar.
Consider updating to Pydantic 2.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.