-
Seasons greetings, all! I'm having some import issues with pytest. In my bases and component files, I use the truncated style of import, e.g. This works well and my IDE can pick it up. However, pytest is having issues with it. I tried setting my pytest options in
But the pytest runner can only ever handle truncated imports from the first element in the pythonpath list. My work around is to just do But I wondered if anyone else has run into this issue, and knows a way of setting up the config so that I can use truncated style imports everywhere in my repo? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello @saifmode! I think it looks correct with your way of importing without the The way your IDE and the tool you use ( I don't think it is necessary to define the paths in a By running pytest within the uv run pytest
# or if you use Poetry
poetry run pytest Make sure the top-level [tool.hatch.build]
dev-mode-dirs = ["components", "bases", "development", "."] After adding this config, I think that you need to run |
Beta Was this translation helpful? Give feedback.
Thanks for getting back! Unfortunately the above didn't fix the issue, as this is basically what I've already been doing.
However, I realised what the problem was. I had
__init__.py
files in thebases/my_app
andcomponents/my_app
directories.Deleting these resolved the issue.