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

Fix Settings.pyenvs to _actually_ use basepath by default #344

Merged
merged 2 commits into from
Jul 31, 2023

Conversation

jherland
Copy link
Member

This is a rather embarrasing omission from PR #326 (Teach FawltyDeps to automatically discover Python environments inside the project):

Although that PR did include code to traverse within a given --pyenv path to find Python environments, the PR "forgot" to actually switch the default behavior of --pyenv:

The default value of settings.pyenvs remained an empty set, and there were no changes to have basepath influence the value of settings.pyenvs.

This PR fixes that:

  • When neither --pyenv nor basepath is given, settings.pyenvs should default to the current directory.
  • When --pyenv is not given, but basepath is given, basepath should override the default settings.pyenvs.
  • When --pyenv is given, it overrides basepath.

In short settings.pyenvs should behave exactly like .code and .deps.


Commits:

  • test_settings: Prepare for including --pyenv in basepath-related tests
  • Fix Settings.pyenvs to actually use basepath by default

jherland added 2 commits July 28, 2023 13:00
We have some test cases that verify correct interaction between
--code/--deps and basepath. We're about to add --pyenv to --code and
--deps as another option that interacts with basepath, and we'd like the
tests to cover this as well.

At this point the various combinations of passing or not passing these
options on the command line are becoming tedious to hardcode.

Instead, provide a `path_options` collection that list these options, and
a subsets() helper function that automatically enumerates the various
combinations of giving or not giving these options the we need in
test_path_option_overrides_base_path().
This is a rather embarrasing omission from PR #326 (Teach FawltyDeps to
automatically discover Python environments inside the project):

Although that PR did include code to traverse within a given --pyenv
path to find Python environments, the PR "forgot" to actually switch the
_default_ behavior of --pyenv:

The default value of settings.pyenvs remained an empty set, and there
were no changes to have basepath influence the value of settings.pyenvs.

This commit fixes that:

- When neither --pyenv nor basepath is given, settings.pyenvs should
  default to the current directory.
- When --pyenv is not given, but basepath is given, basepath should
  override the default settings.pyenvs.
- When --pyenv is given, it overrides basepath.

In short settings.pyenvs should behave exactly like .code and .deps.
@jherland jherland requested review from mknorps and Nour-Mws July 28, 2023 11:07
@jherland jherland added this to the Mapping strategy milestone Jul 28, 2023
@Nour-Mws Nour-Mws self-assigned this Jul 31, 2023
Copy link
Collaborator

@Nour-Mws Nour-Mws left a comment

Choose a reason for hiding this comment

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

Looks good. As usual, it was great to read this well organized and logically evolving PR.
Note that I only checked that the changes make sense and did not verify that no other tests/code should be changed for this to be complete.

tests/test_settings.py Show resolved Hide resolved
tests/test_settings.py Show resolved Hide resolved
@jherland jherland merged commit 04c5b69 into main Jul 31, 2023
@jherland jherland deleted the jherland/fix-pyenvs-default branch July 31, 2023 12:48
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