-
-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behavior from module_to_os_path
#3554
Comments
@ghferrari, do you have an |
Hi @cofin, I think the error above is reproducible if you have a minimal folder/file structure like this:
Use my MCVE above as the contents of
I also have a postgres database running in docker and set my database URL as an environment variable via In you follow this setup, the For me, this produces this error:
As you can see in the final error line, |
@ghferrari I had a chance to re-read this. Let me double check a few things and I'll report back. |
@cofin In case it helps, I tried two things:
|
…3565) * Update module_loader.py * feat: adds a test for single file module --------- Co-authored-by: Cody Fincher <[email protected]>
closed by #3565 |
Description
The file litestar/utils/module_loader.py contains a function definition for
module_to_os_path
.Assuming I've understood the code comments, the purpose of this code is to return the path to a directory, which is either the base directory of the project or (when supplied with the name of a module) the base directory of the module.
Unfortunately, if you define your Litestar object in a file named
app.py
, and there is no other module namedapp
, then this function returns the path to that file. This is already an error given that the intention is to return a path to a directory.I noticed this problem while attempting to set up my own starting configuration following the
litestar-fullstack
repository. This repository defines aBASE_DIR
property at https://github.com/litestar-org/litestar-fullstack/blob/8e6edb90a401778741062a8383ff6e6f354b44dd/src/app/config/base.py#L23 usingmodule_to_os_path
which is then used to define subdirectories for alembic. In my case (using a file namedapp.py
, no module namedapp
), this produces invalid directory pathnames which cannot then be created. For example, when attempting to run as per the MCVE below, I see the error:URL to code causing the issue
litestar/litestar/utils/module_loader.py
Line 21 in 84f51c8
MCVE
Steps to reproduce
Screenshots
"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"
Logs
No response
Litestar Version
2.9.0
Platform
Note
While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered: