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
When trying to hook up structlog to starlite v1.51.12, I got the Pydantic exception below on starting up the app. I tried the same with the litestar v2 beta hello-world app, and it worked. I realize this may not get fixed in v1.51.x. Is there a suggested workaround?
1. clone MRE repo and `poetry install`
2. `poetry run uvicorn main:app`
3. See error
Screenshots
""
Logs
Traceback (most recent call last):
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/bin/uvicorn", line 8, in<module>sys.exit(main())
^^^^^^
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/lib/python3.11/site-packages/uvicorn/main.py", line 410, in main
run(
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/lib/python3.11/site-packages/uvicorn/main.py", line 578, in run
server.run()
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/lib/python3.11/site-packages/uvicorn/server.py", line 61, in run
return asyncio.run(self.serve(sockets=sockets))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
returnfuture.result()
^^^^^^^^^^^^^^^
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/lib/python3.11/site-packages/uvicorn/server.py", line 68, in serve
config.load()
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/lib/python3.11/site-packages/uvicorn/config.py", line 473, in load
self.loaded_app = import_from_string(self.app)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/me/Library/Caches/pypoetry/virtualenvs/starlite-hello-world-cQlwT1sN-py3.11/lib/python3.11/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/me/Developer/kpetersen-rgare/litestar-hello-world/main.py", line 19, in<module>
logging_config = StructLoggingConfig(
^^^^^^^^^^^^^^^^^^^^
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for StructLoggingConfig
wrapper_class
Protocols with non-method members don't support issubclass() (type=type_error)
Litestar Version
1.51.12
Platform
Linux
Mac
Windows
Other (Please specify in the description above)
The text was updated successfully, but these errors were encountered:
Hey, thanks for the quick response. I realized a simple workaround is to create my own structlog config class from the BaseLoggingConfig class that does not inherit from pydantic's BaseModel:
Description
When trying to hook up structlog to starlite v1.51.12, I got the Pydantic exception below on starting up the app. I tried the same with the litestar v2 beta hello-world app, and it worked. I realize this may not get fixed in v1.51.x. Is there a suggested workaround?
URL to code causing the issue
https://github.com/kpetersen-rgare/litestar-hello-world/blob/structlog-logging-config-bug/main.py
MCVE
# see URL to code
Steps to reproduce
Screenshots
""
Logs
Litestar Version
1.51.12
Platform
The text was updated successfully, but these errors were encountered: