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

Loosen pytest reqs to allow upgrade to pytest 7.0.0 + Upgrade to pytest 7 #14380

Merged
merged 13 commits into from Feb 8, 2022

Conversation

asherf
Copy link
Member

@asherf asherf commented Feb 6, 2022

the tight requirements prevents downstream projects from upgrading to pytest 7.0.0

#14383 will need to land first.

@@ -63,7 +63,7 @@ class PyTest(PythonToolBase):
# This should be kept in sync with `requirements.txt`.
# TODO: To fix this, we should allow using a `target_option` referring to a
# `python_requirement` to override the version.
default_version = "pytest>=6.2.4,<6.3"
default_version = "pytest>=6.2.4,<8"
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I think that if we're expecting / have-a-default-lock-of 7, then we shouldn't mention 6 here, and should instead bump the minimum end of the range to the version that you ended up testing with.

While it's possible that folks using plugins while relying on this default value might need to actually set the version if their plugins are no longer compatible with 7, that seems fine to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

why not?
This allows downstream repos that have pants plugins (and thus use pantsbuild.pants.testutil ) use pytest 6.
I don't think keeping tight dependency between pantsbuild.pants.testutil and pytest is a good idea when there is no technical reason I can think of to do so.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

This allows downstream repos that have pants plugins (and thus use pantsbuild.pants.testutil ) use pytest 6.

They can still do that, by explicitly setting the version. This is just the default.

Copy link
Member Author

Choose a reason for hiding this comment

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

nope... it doesn't work. see:
Screen Shot 2022-02-07 at 1 10 06 PM

this is when trying to upgrade a downstream repo (toolchain) that has plugins (and plugin tests) to pytest 7.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, we could have our requirements.txt be loose, but have pytest.py be tighter. Note that pytest.py's version only needs to be compatible with requirements.txt, they don't need to be identical. pytest.py is what is used for the default tool lockfile, whereas requirements.txt gets used by python_distribution for the install_requires of pansbuild.pants.testutil

@Eric-Arellano
Copy link
Contributor

I'm getting 500 errors when trying to review (reported to Github), but ditto Stu's comments on not mentioning Pytest 6. Also probably constraint to <7.1, as their changelog says they will be making API changes in 7.1.

@asherf
Copy link
Member Author

asherf commented Feb 7, 2022

I'm getting 500 errors when trying to review (reported to Github), but ditto Stu's comments on not mentioning Pytest 6. Also probably constraint to <7.1, as their changelog says they will be making API changes in 7.1.

the api changes that are planned are for plugin APIs I think it is not likely that those API changes will break any user facing APIs and thus not those deprecations and changes are not relevant for this repo.
As it stands right now, having such a tight version constraints limits the ability of downstream repos developing plugins against pantsbuild.pants.testutil from upgrading to latest pytest release.
I don't think it is reasonable to require a pants version upgrade in order to be able to upgrade pytest.

@Eric-Arellano
Copy link
Contributor

K, then that's fine to use <8. But I don't think we should include 6.

@asherf
Copy link
Member Author

asherf commented Feb 7, 2022

K, then that's fine to use <8. But I don't think we should include 6.

that will be a bad idea. because it forces downstream repos to upgrade since this line in requirements.txt propagates into dependencies of pantsbuild.pants.testutil
see: #14380 (comment) and #14380 (comment)

@@ -10,7 +10,7 @@
# ],
# "generated_with_requirements": [
# "pytest-cov!=2.12.1,<3.1,>=2.12",
# "pytest<6.3,>=6.2.4"
# "pytest<8,>=6.2.4"
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be regenerated. build-support/bin/generate_all_lockfiles.sh --tool pytest. No need to regenerate --internal though afaict.

@@ -63,7 +63,7 @@ class PyTest(PythonToolBase):
# This should be kept in sync with `requirements.txt`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you - could you also please update the comment here to say:

This should be compatible with requirements.txt, although it can be more precise.

pytest>=6.2.4,<6.3 # This should be kept in sync with `pytest.py`.
pytest>=6.2.4,<8 # This should be kept in sync with `pytest.py`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please update the comment to say this?

This should be compatible with pytest.py, although it can be looser so that we don't over-constrain pantsbuild.pants.testutil

(Will want to move comment above the entry, rather than inline)

@Eric-Arellano Eric-Arellano enabled auto-merge (squash) February 7, 2022 20:50
@Eric-Arellano
Copy link
Contributor

auto-merge was automatically disabled February 7, 2022 23:26

Head branch was pushed to by a user without write access

@Eric-Arellano
Copy link
Contributor

How come the revert for pytest-cov? Is this the final version you want merged?

@asherf
Copy link
Member Author

asherf commented Feb 7, 2022

How come the revert for pytest-cov? Is this the final version you want merged?

it breaks the test, probably because pytest-cov>3 is not compatible with older python versions, so I had to revert it.

@Eric-Arellano Eric-Arellano enabled auto-merge (squash) February 8, 2022 00:09
@Eric-Arellano Eric-Arellano merged commit f56ac9d into pantsbuild:main Feb 8, 2022
@asherf asherf deleted the m2 branch February 8, 2022 01:00
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.

None yet

3 participants