Commit Graph

248 Commits

Author SHA1 Message Date
Damian Shaw 68529081c2
Enforce f-strings via Ruff (#12393) 2023-11-07 09:14:56 +00:00
efflamlemaillet 6dbd9c68f0
Fix hg: "parse error at 0: not a prefix:" (#12373)
Use two hypen argument `--rev=` instead of `-r=`

Co-authored-by: Efflam Lemaillet <elemaillet@logilab.fr>
Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
2023-10-27 11:08:17 +02:00
Pradyun Gedam 389cb799d0
Use `-r=...` instead of `-r ...` for hg
This ensures that the resulting revision can not be misinterpreted as an
option.
2023-10-01 14:45:29 +01:00
Stéphane Bidoul 3b4738cf9a Fix git version parsing issue 2023-09-17 20:06:35 +02:00
Stéphane Bidoul 45468f06d4 Pass revisions options explicitly to mercurial commands 2023-07-01 13:41:34 +02:00
Dimitri Papadopoulos 1273c7a969
Fix typos found by codespell 2022-11-20 13:27:39 +01:00
Jelmer Vernooij d37034ccf4
bazaar: Use lightweight checkouts rather than a full branch clone (#11264) 2022-10-07 19:16:33 +01:00
hauntsaninja b9ec5ddc29 Use --no-implicit-optional for type checking
This makes type checking PEP 484 compliant (as of 2018).
mypy will change its defaults soon.

See:
https://github.com/python/mypy/issues/9091
https://github.com/python/mypy/pull/13401
2022-08-12 18:44:48 -07:00
Pradyun Gedam 1cda23bd6b
Merge pull request #10795 from pradyunsg/better-subprocess-errors 2022-01-27 07:09:18 +00:00
James Gerity 5c24a798b8
Change VCS tooling verbosity along with pip's verbosity (#9639)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
Co-authored-by: Pradyun Gedam <pradyunsg@users.noreply.github.com>
2022-01-25 08:54:02 +00:00
Pradyun Gedam 531c991ef9
Require every `call_subprocess` call-site to pass `command_desc`
This serves as additional context that can be presented in error
messages.
2022-01-25 01:38:22 +00:00
Pavel Safronov 57cd6cf486 Added an explicit warning on parsing git version failure 2021-09-02 07:53:08 +01:00
Jon Dufresne 44a034a131 Move all remaining type comments to annotations
Use the com2ann tool to convert remaining comments to annotations. Now,
no type comments remain.

https://github.com/ilevkivskyi/com2ann

Some types are not available at runtime (e.g. Literal) or require a
forward reference and so were quoted.
2021-08-27 19:02:57 -07:00
Nipunn Koorapati 2d35b8072c Use git's partial clone feature to speed up pip
Clone with --filter=blob:none - as it fetches all
metadata, but only dynamically fetches the blobs as
needed by checkout. Since typically, pip only needs the blobs for
a single revision, this can be a big improvement, especially
when fetching from repositories with a lot of history,
particularly on slower network connections.

Added unit test for the rev-less path. Confirmed that both
of the if/else paths are tested by the unit tests.
2021-08-13 11:44:01 -07:00
Jon Dufresne 219def7e10 Blacken src/pip/_internal/vcs directory 2021-08-12 07:45:42 -07:00
Jon Dufresne 6a6561c2cb Move many type comments to annotations
Use the tool com2ann to automatically convert most type comments to type
annotations. Some type comments continue to exist where any work beyond
the automatic conversion was required (for example, additional
formatting or circular references).

For additional information on the com2ann tool, see:
https://github.com/ilevkivskyi/com2ann
2021-08-10 07:12:32 -07:00
Jon Dufresne 3991bbca68 Precise type of on_returncode argument to call_subprocess()
It can only be one of 3 literal values: "raise", "warn", "ignore".
2021-08-09 16:11:37 -07:00
Harutaka Kawamura 567282724d
Log commit SHA when installing package via Git URI (#10149)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2021-07-22 15:29:16 +08:00
Tzu-ping Chung 72e38ca3df Re-implement Git version parsing with regex
After packaging drops LegacyVersion, version.parse() will no longer
guarantee to be able to parse Git versions, so we need to invent our own
parser. Since we really only care about the major and minor segments,
the logic is pretty simple.
2021-07-02 19:03:15 +08:00
Tzu-ping Chung 288bffc43c Unify Python project root detection logic
A Python project root is now defined as containing a pyproject.toml, or
a setup.py (pre-PEP-517 legacy layout). After this patch, this logic
applies to all checks except parse_editable, where we check for setup.py
and setup.cfg instead since non-setuptools PEP 517 projects cannot be
installed as editable right now.
2021-06-19 15:29:04 +08:00
Tzu-ping Chung b38b925400
Merge pull request #9822 from bwoodsend/fix-pip-freeze-git 2021-06-04 18:58:15 +08:00
bwoodsend 8b8fa2bd5f Explicitly recognise SCP-shorthand git remotes. 2021-06-03 17:52:25 +01:00
bwoodsend f533671b0c Fix pip freeze to use modern format for git repos (#9822)
Pip dropped support for `git+ssh@` style requirements (see #7554)
in favour of `git+ssh://` but didn't propagate the change to
 `pip freeze` which resultantly returns invalid requirements.
Fix this behaviour.

Fixes #9625.
2021-06-03 17:45:56 +01:00
Pradyun Gedam ca832b2836
Don't split git references on unicode separators
Previously, maliciously formatted tags could be used to hijack a
commit-based pin. Using the fact that the split here allowed for
all of unicode's whitespace characters as separators -- which git allows
as a part of a tag name -- it is possible to force a different revision
to be installed; if an attacker gains access to the repository.

This change stops splitting the string on unicode characters, by forcing
the splits to happen on newlines and ASCII spaces.
2021-04-24 10:19:03 +01:00
Stéphane Bidoul ecdcfeb8d6 Remove now unused VCS export code 2021-04-03 15:44:00 +02:00
Laurent LAPORTE f162f9d849 Correct the coding-style in `VersionControl.run_command()` to use f-string instead of `.format(**locals())`. 2021-03-24 20:26:17 +01:00
Laurent LAPORTE 35c21e936f Add a section in the documentation to suggest solutions to the ``pip freeze`` permission denied issue. Update link in source code. 2021-03-24 20:26:17 +01:00
Laurent LAPORTE 38160547f9 run_command() raises BadCommand if the user don't have permission to run the VCS command. 2021-03-24 20:26:17 +01:00
Tzu-ping Chung 40e395d6be Avoid pkg_resources API in versioncontrol 2021-02-23 01:10:37 +08:00
Pradyun Gedam c2ba7c043b
Merge pull request #9606 from hexagonrecursion/fstr 2021-02-21 08:30:00 +00:00
Jon Dufresne 0945809afc Remove typing.TYPE_CHECKING guards
The typing module has been available since Python 3.5. Guarding the
import has been unnecessary since dropping Python 2.

Some guards remain to either:

- Avoid circular imports
- Importing objects that are also guarded by typing.TYPE_CHECKING
- Avoid mypy_extensions dependency
2021-02-19 18:34:21 -08:00
Jon Dufresne a6392bd62e Replace pip._internal.utils.typing with stdlib typing
The stdlib module has been available since Python 3.5 and the
TYPE_CHECKING constant has been available since 3.5.2.

By using stdlib, this removes the need for pip to maintain its own
Python 2 typing compatibility shim.
2021-02-18 19:09:13 -08:00
Tzu-ping Chung 503e6d6f33
Merge pull request #9413 from jdufresne/type-vcs
Complete type annotations for the vcs package
2021-02-18 18:41:03 +08:00
Andrey Bienkowski 9b2cb894ba Convert more str.format() calls to f-strings 2021-02-13 09:27:17 +03:00
Stéphane Bidoul 78b891a6d1
Remove unused VCS schemes
These schemes without + are support in an ad-hoc fashion in
parse_editable_requirement.
2021-01-18 09:11:08 +01:00
Stéphane Bidoul b3761f6fab
Remove support for git+git@ pseudo VCS URLs.
Now that we don't need to support git@
pseudo-urls, we can simplify the test for
valid VCS URLs based on link.is_vcs, which
is turns is based on the URL scheme.

This also means we fail earlier if a git@ pseudo
URL is used.

Since VCS requirements are not validated to be URLs
in Requirement constructors, we can simplify update_editable.
2021-01-18 09:11:07 +01:00
Jon Dufresne c985454b42 Complete type annotations for the vcs package 2021-01-12 18:59:08 -08:00
Pradyun Gedam 9b83654de8
Merge pull request #9331 from sbidoul/7969-revert-sbi
Revert #7969 and fix VCS stdout/stderr capture
2021-01-09 21:09:04 +00:00
Stéphane Bidoul 35604e5a4c
Merge pull request #9403 from jdufresne/get-revision
Harmonize return type of VersionControl.get_revision in subclasses
2021-01-01 19:36:20 +01:00
Jon Dufresne ca053fbe88 Handle ._get_svn_url_rev() returning None in .get_remote_url()
The method Subversion._get_svn_url_rev() will sometimes return None for
a remote URL. The calling code should handle this. If it is None, raise
a RemoteNotFoundError as prescribed by the parent class docstring.

Followup to 0b761a164c.
2020-12-31 14:36:58 -08:00
Jon Dufresne c513c5e890 Harmonize return type of VersionControl.get_revision in subclasses
Previously, the Subversion subclass violated the parent's type signature
by returning an int, but it is now coerced to a str to match the
expected signature.
2020-12-30 11:25:29 -08:00
Stéphane Bidoul b3d348d6e7
Merge remote-tracking branch 'upstream/master' into 7969-revert-sbi 2020-12-27 17:01:58 +01:00
Stéphane Bidoul 74369e860e
vcs: capture subprocess stdout only 2020-12-27 16:54:57 +01:00
Stéphane Bidoul bcc412c44a
Additional revert of 7969
Revert additional changes that were made
after 7969 and depended on it.
2020-12-27 16:54:57 +01:00
Stéphane Bidoul 8665a3e1e2
Revert "Improve check for svn version string"
This reverts commit 1471897b84.
2020-12-27 16:54:57 +01:00
Stéphane Bidoul eda67075c1
Revert "Create call_subprocess just for vcs commands"
This reverts commit 8adbc216a6.
2020-12-27 16:54:56 +01:00
Stéphane Bidoul 6693a71e0a
Revert "Remove show_stdout from run_command args"
This reverts commit 94882fd1ed.
2020-12-27 16:54:56 +01:00
Stéphane Bidoul 6480bed441
Revert "Remove on_returncode parameter from call_subprocess"
This reverts commit ab3ee7191c.
2020-12-27 16:54:56 +01:00
Hugo van Kemenade a3e246f7d0 Cleanup: replace 'from urllib import xyz as urllib_xyz' with import urllib.xyz 2020-12-27 16:18:44 +02:00
Jon Dufresne d282fb94a3 Use unified OSError and its subclasses
Since Python 3.3, the following classes have merged into OSError. They
remain as aliases for backward compatibility.

- EnvironmentError
- IOError
- WindowsError

https://docs.python.org/3/library/exceptions.html#OSError

Python 3 also has subclasses of OSError to help identify more specific
errors. For example, FileNotFoundError. This allows simplifying some
except blocks.
2020-12-26 12:16:09 -08:00