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

Proposal: root spec import mode to replace legacy importing and importmode #10824

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RonnyPfannschmidt
Copy link
Member

this pr is a starting point for a import-mode that supports modern importing

the key ideas are

  • correctly setup import toplevels
  • in case of non-editable installation compare files to correctly fail collection when reinstall is needed

@RonnyPfannschmidt RonnyPfannschmidt force-pushed the draft-importmode-rootspec branch from a03a8fa to c37f550 Compare March 20, 2023 15:27
@RonnyPfannschmidt
Copy link
Member Author

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

@RonnyPfannschmidt
Copy link
Member Author

@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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to adjust this

Comment on lines +16 to +17
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is installation done? Like pytest will install to the venv with pip?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,

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

Successfully merging this pull request may close these issues.

2 participants