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
While developing it appears that I accidentally caused a circular import which Python traces back to starting in the file I have my app in. As a result, Python outputs an error such as the following:
ImportError: cannot import name 'constants' from partially initialized module 'app' (most likely due to a circular import) (/api/app/__init__.py)
In this case my module I pass to the sanic server is app:app, from within /api.
Code snippet
No response
Expected Behavior
I had this in the back of my mind the entire time, but found it very difficult to troubleshoot due to Sanic swallowing the error. As a result I ended up the rabbit hole of accidental breaking changes and tried commenting out different changes. An hour later I finally found the right import.
It would help if Sanic continued to output the specific import error, on the off-chance that it isn't an incorrectly setup module. The alternative would be to use more fine-grained importlib and manually call some functions rather than use their help functions. As a result there should be a different call which finds the file (an ImportError here hints at an incorrectly setup module), than the one which loads it (user error).
How do you run Sanic?
Sanic CLI
Operating System
Windows (Docker, Python:3.11)
Sanic Version
23.3
Additional context
No response
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Describe the bug
While developing it appears that I accidentally caused a circular import which Python traces back to starting in the file I have my app in. As a result, Python outputs an error such as the following:
In this case my module I pass to the sanic server is
app:app
, from within/api
.Code snippet
No response
Expected Behavior
I had this in the back of my mind the entire time, but found it very difficult to troubleshoot due to Sanic swallowing the error. As a result I ended up the rabbit hole of accidental breaking changes and tried commenting out different changes. An hour later I finally found the right import.
It would help if Sanic continued to output the specific import error, on the off-chance that it isn't an incorrectly setup module. The alternative would be to use more fine-grained
importlib
and manually call some functions rather than use their help functions. As a result there should be a different call which finds the file (anImportError
here hints at an incorrectly setup module), than the one which loads it (user error).How do you run Sanic?
Sanic CLI
Operating System
Windows (Docker, Python:3.11)
Sanic Version
23.3
Additional context
No response
The text was updated successfully, but these errors were encountered: