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
raiseImportError(f"Can't find module {path.stem!r} at location {path}.")
mod=importlib_util.module_from_spec(spec)
spec.loader.exec_module(mod)
, the module spec is created with a module name of path.stem, so in my case it is task_a. But then IFF you have used a from __future__ import annotations, then you go down this code path where dataclasses tries to call sys.modules.get("task_a"), and "task_a" is not importable by itself.
I think we need to be setting the module.name to something else, so it actually is findable within sys.modules, or import/exec it slightly differently?
Expected Output
The text was updated successfully, but these errors were encountered:
Hi @NickCrews, thanks for the kind words, and thank you for the bug report + test 🙇.
This seems tricky. I hopefully have some time over the weekend to look into this. My current guess is that the import mechanism is not doing enough, and maybe it needs some of the sys.path modification magic pytest is doing. Here for future investigations:
main
branch of pytask.Problem description
First of all, thanks for this library! A lot of great stuff in here.
See #373 for a PR that adds a failing test.
While I'm not sure what the root cause is / who's fault it is, the actual method of failure is something like this:
Say I have a file
task_a.py
. Inpytask/src/_pytask/collect.py
Lines 108 to 120 in 9b2d93e
path.stem
, so in my case it istask_a
. But then IFF you have used afrom __future__ import annotations
, then you go down this code path where dataclasses tries to callsys.modules.get("task_a")
, and "task_a" is not importable by itself.I think we need to be setting the module.name to something else, so it actually is findable within sys.modules, or import/exec it slightly differently?
Expected Output
The text was updated successfully, but these errors were encountered: