Proposal: root spec import mode to replace legacy importing and importmode - #10824
Proposal: root spec import mode to replace legacy importing and importmode#10824RonnyPfannschmidt wants to merge 3 commits into
Conversation
a03a8fa to
c37f550
Compare
|
Note on implementation, This will require py3.9+ importlib_metadata apis for the details on resource An accompanying note to migrate to their apis seems necessary (so that pytest can warn on stale resources as well The best way to register test root namespaces is still unclear |
|
@bluetech i wonder if this proposal/idea could integrate with directory/package collection enhancements/changes in a way that allows migration |
| :orphan: | ||
|
|
||
| =================================== | ||
| PROPOSAL: Parametrize with fixtures |
| test module discovery in pytest currently is is pre-pep40 and create pains for users | ||
| by adding anything things to sys.path and creating easy conflicts in sys.modules |
There was a problem hiding this comment.
| test module discovery in pytest currently is is pre-pep40 and create pains for users | |
| by adding anything things to sys.path and creating easy conflicts in sys.modules | |
| Test module discovery in pytest currently is is pre-PEP420 and creates pain for users | |
| by adding things to ``sys.path`` and creating easy conflicts in ``sys.modules``. |
| A new import mode take a definition of import roots. | ||
|
|
||
| a import root is either a folder in the worktree that will no be installed, | ||
| or a folder that will be installed either normally or editable. |
There was a problem hiding this comment.
How is installation done? Like pytest will install to the venv with pip?
There was a problem hiding this comment.
Users Will have to manage install, pytest should never do that part
|
|
||
| In any case pytest will collect the file tree in the working directory. | ||
|
|
||
| If normal install us used and the content of the imported file differs from the working directory, |
There was a problem hiding this comment.
| If normal install us used and the content of the imported file differs from the working directory, | |
| If normal install is used and the content of the imported file differs from the working directory, |
|
... any chance this proposal might happen? (I realize that's probably just asking if anyone is going to take on the work and I"m not here volunteering so... mostly just poking it to see if there is interest) |
|
I have 2 refactoring of horror higher on my priority Lust ans im currently very thin stretched for time on that |
Rename the proposal from importmode_root_spec to import_roots and reposition it as a declarative alternative that replaces --import-mode instead of adding a fourth mode: * update the problem statement for the pytest 8 importlib rework (real module names, sys.modules insertion) and ground it in the modern import system (PEP 420/451/610/660, importlib.metadata) * specify implied roots for simple layouts with a hard failure on ambiguity instead of guessing * specify minimal editable vs real vs stale install classification via PEP 610 direct_url.json, with StaleInstallError on divergence * fix the copy-pasted title and turn the todo notes into a proper test case matrix Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collection targets must map to exactly one root, testpaths entries act as an inference signal for local roots, and conftest files above every root are recorded as an open naming question. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
c37f550 to
e690aff
Compare
this pr is a starting point for a import-mode that supports modern importing
the key ideas are