redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.12k stars 112 forks source link

mypy errors #468

Open tyki6 opened 1 year ago

tyki6 commented 1 year ago

Hello, when I run mypy on my project, I got some errors. Can you help me? Regards,

Example

import os
from datetime import datetime

from redis_om import EmbeddedJsonModel
from redis_om import Field
from redis_om import get_redis_connection
from redis_om import JsonModel

class Message(EmbeddedJsonModel):
    content: str = Field(index=True)
    id: str = Field(index=True)

class Conversation(JsonModel):
    messages: list[Message] = Field(index=True)
    class Meta:
        database = get_redis_connection(
            url="myredis",
            decode_responses=True,
        )

mypy

Conf file

[mypy]
plugins = sqlalchemy.ext.mypy.plugin
ignore_missing_imports = True
warn_return_any = True
warn_unused_configs = True
follow_imports = normal
show_column_numbers = True
pretty = False
strict = True

Command

mypy .

Output

error: Class cannot subclass "EmbeddedJsonModel" (has type "Any")  [misc]
error: Class cannot subclass "JsonModel" (has type "Any")  [misc]

Package Version

redis-om==0.1.2
  - hiredis [required: >=2.0.0,<3.0.0, installed: 2.1.1]
  - redis [required: >=3.5.3,<5.0.0, installed: 4.4.2]
  - types-redis [required: >=3.5.9,<5.0.0, installed: 4.4.0.3]
mypy-extensions [required: >=0.4.3, installed: 0.4.3]
mypy [required: >=0.780, installed: 0.991]
asdrubalivan commented 1 year ago

I'm getting the same error here

class Delivery(HashModel):
    budget: int = 0
    notes: str = ""

    class Meta:
        database = redis

So far only using type: ignore has helped. Have you found another workaround?

tyki6 commented 1 year ago

I'm getting the same error here

class Delivery(HashModel):
    budget: int = 0
    notes: str = ""

    class Meta:
        database = redis

So far only using type: ignore has helped. Have you found another workaround?

i did same thing, i'm still waiting a proper solution