Coder Social home page Coder Social logo

pycql2's Issues

Cannot import module

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< --

Explore Generics for Accenti / Casei

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.

Add Hypothesis tests for the Pydantic models.

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.

Document Usage

Currently the only way to determine usage is looking at the tests.

  • Include explanations about the extensive usage of __root__ throughout the models.
  • Explain cases where the grammar can parse, but not transform. Such as bad dates.
  • Explain cases where the pydantic model may output bad text. Such as weird characters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.