redis-om-python icon indicating copy to clipboard operation
redis-om-python copied to clipboard

Running example script failed with an error 'TypeError: Plain typing.NoReturn is not valid as type argument'

Open wangyihanlarry opened this issue 1 year ago • 0 comments

Hi All,

The following code failed exeuction, is there any thing wrong?

`import datetime from typing import Optional from pydantic import EmailStr from redis_om import ( Field, HashModel, Migrator, get_redis_connection )

class Customer(HashModel): first_name: str last_name: str = Field(index=True) email: EmailStr join_date: datetime.date age: int = Field(index=True) bio: Optional[str]

class Meta:
     database = redis

redis = get_redis_connection(port="port", host='ip, password='password', db=1, decode_responses=True) Migrator().run()

Customer.find(Customer.last_name == "Brookins").all()

Customer.find(Customer.last_name != "Brookins").all()

Customer.find((Customer.last_name == "Brookins") | ( Customer.age == 100 ) & (Customer.last_name == "Smith")).all() `

[root@VM_149_39_centos ~/CFS_MS]# cd /root/CFS_MS ; /usr/bin/env /usr/local/bin/python3.7 /root/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/lib/python/debugpy/launcher 35168 -- /root/CFS_MS/test.py Traceback (most recent call last): File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/root/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module> cli.main() File "/root/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 444, in main run() File "/root/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 285, in run_file runpy.run_path(target_as_str, run_name=compat.force_str("__main__")) File "/usr/local/lib/python3.7/runpy.py", line 263, in run_path pkg_name=pkg_name, script_name=fname) File "/usr/local/lib/python3.7/runpy.py", line 96, in _run_module_code mod_name, mod_spec, pkg_name, script_name) File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/root/CFS_MS/test.py", line 33, in <module> Migrator().run() File "/usr/local/lib/python3.7/site-packages/redis_om/model/migrations/migrator.py", line 163, in run self.detect_migrations() File "/usr/local/lib/python3.7/site-packages/redis_om/model/migrations/migrator.py", line 118, in detect_migrations conn.ft(cls.Meta.index_name).info() File "/usr/local/lib/python3.7/site-packages/redis/commands/redismodules.py", line 20, in ft from .search import Search File "/usr/local/lib/python3.7/site-packages/redis/commands/search/__init__.py", line 3, in <module> from ...asyncio.client import Pipeline as AsyncioPipeline File "/usr/local/lib/python3.7/site-packages/redis/asyncio/__init__.py", line 1, in <module> from redis.asyncio.client import Redis, StrictRedis File "/usr/local/lib/python3.7/site-packages/redis/asyncio/client.py", line 626, in <module> class PubSub: File "/usr/local/lib/python3.7/site-packages/redis/asyncio/client.py", line 693, in PubSub def close(self) -> Awaitable[NoReturn]: File "/usr/local/lib/python3.7/typing.py", line 251, in inner return func(*args, **kwds) File "/usr/local/lib/python3.7/typing.py", line 626, in __getitem__ params = tuple(_type_check(p, msg) for p in params) File "/usr/local/lib/python3.7/typing.py", line 626, in <genexpr> params = tuple(_type_check(p, msg) for p in params) File "/usr/local/lib/python3.7/typing.py", line 135, in _type_check raise TypeError(f"Plain {arg} is not valid as type argument") TypeError: Plain typing.NoReturn is not valid as type argument

wangyihanlarry avatar Dec 18 '22 09:12 wangyihanlarry