You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the odmantic 1.0.0 examples and trying to upgrade odmantic/pydantic to V2 , I can find several issues in mypy.
Errors explained as comments below.
Current Behavior
from typing import Optional
from motor.core import AgnosticCollection
from odmantic import Model, Field
from odmantic.config import ODMConfigDict
class A(Model):
test: Optional[str] = Field(default=None)
# Missing named argument "id" for "A" Mypy (call-arg)
A(test="bla")
class B(Model):
# Extra key "indexes" for TypedDict "ConfigDict" Mypy (typeddict-unknown-key)
model_config = {"collection": "B"}
# Fixed: using type explicitly
class B_OK(Model):
model_config = ODMConfigDict(collection="B")
from odmantic import AIOEngine, Model
engine = AIOEngine()
collection = engine.get_collection(B_OK)
# AsyncIOMotorCollection? has no attribute "find" Mypy (attr-defined)
collection.find({})
# This fixes the issue
collection2: AgnosticCollection = engine.get_collection(B_OK)
Bug
Following the odmantic 1.0.0 examples and trying to upgrade odmantic/pydantic to V2 , I can find several issues in mypy.
Errors explained as comments below.
Current Behavior
Environment
pydantic-core version: 2.14.5
pydantic-core build: profile=release pgo=true
install path: /home/sander/Projects/application.status.backend/.venv/lib/python3.9/site-packages/pydantic
python version: 3.9.18 (main, Aug 25 2023, 13:20:14) [GCC 11.4.0]
platform: Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
related packages: mypy-1.7.1 typing_extensions-4.9.0 fastapi-0.105.0
The text was updated successfully, but these errors were encountered: