Skip to content
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

Running Example app results in "ImportError: attempted relative import with no known parent package" #199

Open
danielMicallef opened this issue Sep 23, 2021 · 2 comments

Comments

@danielMicallef
Copy link

When generating an app with the example yaml file provided generates failing relative imports (using Python 3.8)

The import created from .models import Pets should be updated to from models import Pets

Issue is probably caused here: https://github.com/koxudaxi/fastapi-code-generator/blob/master/fastapi_code_generator/__main__.py#L75

@koxudaxi
Copy link
Owner

koxudaxi commented Oct 6, 2021

I'm sorry for the late reply.
If we remove . then It can't be worked.
If you would like to avoid the warning we should use an absolute path like from app.models import Pets

@cardellcr
Copy link

Hello, any plan on fix this issue??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants