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
fix: Ensure app-dir is appended to path during autodiscovery. #2277
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote a test that I will push to your branch. I hope you don't mind.
Also, the env is resolved here:
Line 53 in c36dba2
ctx.obj = lambda: LitestarEnv.from_env(app_path) |
I don't know yet the exact conditions on which this line is invoked, but it is important as removing this line causes a lot of test failures. You may want to follow this further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added app_dir
to the line mentioned in my comments just in case. Other than that, it's all good.
Congratulations on your first contribution to Litestar 👍
4fda9b7
to
df13c63
Compare
df13c63
to
6a132f6
Compare
I feel like we need to override the path that's passed into the One way to do that would be to override the cwd = Path().cwd() if app_dir is None else Path(app_dir)
cwd_str_path = str(cwd)
if cwd_str_path not in sys.path:
sys.path.append(cwd_str_path) You would then remove the additional |
I just tried it, lots of failures, all in |
Nice work! |
@all-contributors add @sykloid for bugs, code, and tests |
I've put up a pull request to add @sykloid! 🎉 |
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/2277 |
Pull Request Checklist
Description
--app-dir
option to thelitestar
CLI to not be propagated during autodiscovery.Close Issue(s)
--app-dir
option does not work/fails during autodiscovery. #2266Notes
I am unclear what kind of tests should be written for this, since the existing test should capture it, yet I'm not sure why it doesn't.