-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
Add experimental tool lockfiles for Black, Isort, Yapf, Coverage.py, Lambdex, and Protobuf MyPy #12357
Conversation
…x, and Protobuf MyPy # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
Blocked by #12200. The Black lockfile generated w/ Py36 does not work with 3.9, and vice versa. It can be fixed by manually adding environment markers. |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! One thing that would be fine in a followup.
Also, the title needs an update to remove black
, maybe? Or have we still added the support, but not enabled it yet?
# Register the UnionRule. | ||
register_lockfile: ClassVar[bool] = False | ||
default_lockfile_resource: ClassVar[tuple[str, str] | None] = None | ||
default_lockfile_file_path: ClassVar[str | None] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this the first time around, but: the fact that this gets baked into a Github URL will result in an incorrect URL if someone outside of the pantsbuild/pants
repo declares a PythonToolRequirementsBase
instance in a plugin.
Maybe make the field optional (even when default_lockfile_resource
is set), and then declare it as:
default_lockfile_file_url: ClassVar[str | None] = None
...and have instances in pantsbuild/pants
call git_url(cls.default_lockfile_file_path)
explicitly? Callers outside the repo could construct a URL or not if they didn't want to bother.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, good point. Will fix here.
Yeah, Black support is technically added. Just the default file is not going to work if you don't use Python 3.6. But you can still generate your own lockfile. |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
…more-lockfiles [ci skip-rust] [ci skip-build-wheels]
These tool lockfiles are trickier than #12357 because they get their interpreter constraints from the users' code, rather than subsystems. So, when generating a lockfile, we query all their code to calculate the constraint. It's even trickier that Bandit and Flake8 partition by interpreter constraints, e.g. Py27 code running separately than Py37. Ideally, the single lockfile will be compatible with all partitions. To do this, we OR each distinct IC encountered. Using the technique from #12389, we'll try to generate a lockfile for each possible interpreter and then will merge into a single lockfile. Finally, this updates Black's generation to mirror our actual logic: if the user's code is Py38+ only, we automatically default to the ICs being Py38+ instead of Py36+. -- With this PR, we have now implemented lockfiles for: - Bandit - Black - Docformatter - Flake8 - isort - Yapf - Coverage.py - Lambdex - Protobuf MyPy plugin - setuptools These remain: - MyPy - Pylint - Pytest - IPython - pip-tools [ci skip-rust] [ci skip-build-wheels]
These tools are simple to support: they run entirely independently of user code, and they get their interpreter constraints from a subsystem rather than from user code.
*Black is temporarily not used because it does not play nicely with interpreter constraints: #12200.
Tools that still need lockfiles
Need to consider user interpreter constraints:
Need to be mixed into user lockfiles (or have shading):