Closed brutalsuperman closed 2 weeks ago
From the error message, it seems to me that you are using Python 3.9. If you look at the RootConfigs class in properties.py you will find that the type of ROOT_DIR property is given using the "|" operator. This operator is only supported in versions of Python 3.10+. You can either upgrade your version of Python or modify the RootConfigs class like this:
from typing import Union
@dataclass
class RootConfigs:
ROOT_DIR: Union[str, pathlib.Path]
...
From the error message, it seems to me that you are using Python 3.9. If you look at the RootConfigs class in properties.py you will find that the type of ROOT_DIR property is given using the "|" operator. This operator is only supported in versions of Python 3.10+. You can either upgrade your version of Python or modify the RootConfigs class like this:
from typing import Union @dataclass class RootConfigs: ROOT_DIR: Union[str, pathlib.Path] ...
I will resolve the problem.
@brutalsuperman the problem fixed successfully. [FIX] type error for union has been fixed #42
`Traceback (most recent call last): File "/opt/pyenv/versions/sem-app/bin/uvicorn", line 8, in
sys.exit(main())
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/click/core.py", line 1157, in call
return self.main(args, kwargs)
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, ctx.params)
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/click/core.py", line 783, in invoke
return __callback(args, **kwargs)
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/uvicorn/main.py", line 418, in main
run(
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/uvicorn/main.py", line 587, in run
server.run()
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/uvicorn/server.py", line 62, in run
return asyncio.run(self.serve(sockets=sockets))
File "/opt/pyenv/versions/3.9.4/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/uvicorn/server.py", line 69, in serve
config.load()
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/uvicorn/config.py", line 458, in load
self.loaded_app = import_from_string(self.app)
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "/opt/pyenv/versions/3.9.4/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 790, in exec_module
File "", line 228, in _call_with_frames_removed
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/module_name/my_app_name/main.py", line 8, in
from fastapi_babel import Babel, BabelConfigs
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/fastapibabel/init.py", line 1, in
from .core import Babel, BabelCli,
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/fastapi_babel/core.py", line 11, in
from .properties import RootConfigs
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/fastapi_babel/properties.py", line 7, in
class RootConfigs:
File "/opt/pyenv/versions/3.9.4/envs/sem-app/lib/python3.9/site-packages/fastapi_babel/properties.py", line 9, in RootConfigs
ROOT_DIR: str | pathlib.Path
TypeError: unsupported operand type(s) for |: 'type' and 'type'`