summaryrefslogtreecommitdiff
path: root/src/pip/_internal/utils
Commit message (Collapse)AuthorAgeFilesLines
* Fixed --editable install for setuptools projects without setup.py.KOLANICH2021-03-031-3/+5
| | | | | Co-Authored-By: Tzu-ping Chung <uranusjr@gmail.com> Co-Authored-By: Pradyun Gedam <3275593+pradyunsg@users.noreply.github.com>
* Merge pull request #9636 from dwt/masterTzu-ping Chung2021-02-281-1/+1
|\
| * Remove dead codeMartin Häcker2021-02-201-1/+0
| |
| * Fix --target not working with --editable as setup.py develop does not ↵Martin Häcker2021-02-201-1/+2
| | | | | | | | | | | | understand --home but instead requires the --install-dir option. Parially fixes #4390
* | Use super() for Python 2 old-style classesJon Dufresne2021-02-231-2/+2
| | | | | | | | Followup to c148bcc1aa4025a9dae5bcdabe1a1e01e6df28e5.
* | Handle several mypy TODO comments and exceptionsJon Dufresne2021-02-225-25/+79
| | | | | | | | Remove mypy exceptions that are straightforward to remove.
* | Blacken src/pip/_internal/utils directoryJon Dufresne2021-02-2123-442/+403
| |
* | Merge pull request #9419 from jdufresne/compat-simplifyPradyun Gedam2021-02-212-90/+5
|\ \
| * | Annotate variables assigned stdout lines as strJon Dufresne2021-02-201-1/+1
| | |
| * | Remove str_to_display/console_to_str in favor of subprocess decodingJon Dufresne2021-02-202-81/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since Python 3.6, subprocess supports decoding stdout and stderr. Like before, decoding errors are handled using "backslashreplace". One difference: In the event of a decoding error, pip previously logged a warning before trying again with "backslashreplace". Subprocess does not log such a warning.
| * | Simplify str_to_display() and its usesJon Dufresne2021-02-202-12/+4
| | | | | | | | | | | | | | | | | | | | | | | | With Python 2 dropped, only bytes need to be handled. Passing str was a nop. These bytes/str boundaries are much clearer now. There remains one use of str_to_display(): constole_to_str(). It converts subprocess bytes output to str while handling decoding errors.
* | | Merge pull request #9606 from hexagonrecursion/fstrPradyun Gedam2021-02-212-6/+3
|\ \ \ | |/ / |/| |
| * | Convert more str.format() calls to f-stringsAndrey Bienkowski2021-02-132-6/+3
| | |
* | | Merge pull request #9415 from jdufresne/path_to_displayPradyun Gedam2021-02-202-27/+2
|\ \ \ | |_|/ |/| | Remove Python 2 compat shim path_to_display()
| * | Remove Python 2 compat shim path_to_display()Jon Dufresne2021-02-192-27/+2
| | | | | | | | | | | | | | | | | | Per the function's type signature, this accepted either a str or None. In both cases, the value was returned unaltered. Since dropping Python 2, it has been unnecessary.
* | | Remove typing.TYPE_CHECKING guardsJon Dufresne2021-02-1924-137/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Prefer stdlib contextlib over contextlib2 when availableJon Dufresne2021-02-191-3/+1
|/ / | | | | | | | | | | | | | | | | | | | | Removes the vendored contextlib2. ExitStack and suppress are available from stdlib contextlib on all supported Python versions. The nullcontext context manager which isn't available in Python 3.6, but the function is simple to implement. Once Python 3.6 support is dropped, so too can the compat shim.
* | Incorporate get_installed_version() logicTzu-ping Chung2021-02-191-21/+1
| | | | | | | | | | | | | | All usages of it now use Environment.get_distribution() instead. InstallRequirement.installed_version is also removed since it is no longer used anywhere in the code base.
* | Replace pip._internal.utils.typing with stdlib typingJon Dufresne2021-02-1825-97/+50
| | | | | | | | | | | | | | | | 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.
* | Merge pull request #9368 from jdufresne/ensureTzu-ping Chung2021-02-183-27/+6
|\ \ | | | | | | Remove unnecessary uses of six.ensure_(binary|str|text)
| * | Remove unnecessary uses of six.ensure_(binary|str|text)Jon Dufresne2020-12-273-27/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that Python 2 is not supported, the bytes/str boundaries are more clear and explicit. Using six.ensure_* methods for backwards compatibility is no longer necessary as the types are known and verified using mypy. One exception is tests/lib/wheel.py which allows tests to pass test setup data as either bytes or str. The module operations.install.wheel also remains untouched as it is especially delicate to bytes/str mixups and the current version is working.
* | | Merge pull request #9412 from jdufresne/kwargsTzu-ping Chung2021-02-181-2/+12
|\ \ \ | |_|/ |/| | Use keyword-only arguments
| * | Use keyword-only argumentsJon Dufresne2021-01-291-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://www.python.org/dev/peps/pep-3102/ Replaces the pattern: self.name = kwargs.pop('name') Keyword-only arguments offer some advantages: - In the event of a typo or misuse, a more informative error is presented to the programmer. - More self documenting and makes interfaces more explicit. - They more easily allow explicit typing. Adding types to ConfigOptionParser required changing some call sites to pass arguments without using a dict due to mypy bug: https://github.com/python/mypy/issues/9676
* | | Merge pull request #8114 from uranusjr/importlib-metadataTzu-ping Chung2021-02-031-95/+22
|\ \ \ | |/ / |/| |
| * | Separate default and ad-hoc environment APIsTzu-ping Chung2021-01-191-4/+9
| | | | | | | | | | | | | | | | | | pkg_resources performs annoying caching that needs to be worked around in some parts of pip. This makes it easier to represent the difference between environments backend by WorkingSet() and working_set.
| * | Move dist-related logic from misc into metadataTzu-ping Chung2021-01-191-99/+21
| | |
* | | Use our own copy of strtobool, rather than the one from distutilsPaul Moore2021-01-201-0/+17
|/ /
* | Merge pull request #9367 from hugovk/rm-2-default_time_formatXavier Fernandez2021-01-131-3/+2
|\ \ | | | | | | Use Formatter.default_time_format after dropping PY2
| * | Use Formatter.default_time_format after dropping PY2Hugo van Kemenade2020-12-271-3/+2
| | |
* | | Merge pull request #9331 from sbidoul/7969-revert-sbiPradyun Gedam2021-01-091-25/+50
|\ \ \ | | | | | | | | Revert #7969 and fix VCS stdout/stderr capture
| * \ \ Merge remote-tracking branch 'upstream/master' into 7969-revert-sbiStéphane Bidoul2020-12-2722-360/+118
| |\ \ \ | | | |/ | | |/|
| * | | vcs: capture subprocess stdout onlyStéphane Bidoul2020-12-271-5/+5
| | | |
| * | | add stdout_only to call_subprocessStéphane Bidoul2020-12-271-22/+47
| | | |
* | | | Merge pull request #9375 from jdufresne/dict-set-comprehensionXavier Fernandez2021-01-071-1/+1
|\ \ \ \ | | | | | | | | | | Use dict and set comprehension where available
| * | | | Use dict and set comprehension where availableJon Dufresne2020-12-271-1/+1
| | |/ / | |/| |
* | | | Remove unused utility function consume()Jon Dufresne2021-01-011-6/+0
| | | | | | | | | | | | | | | | Unused since e706af20fe9e73cab3482b1f34b5510e88909506.
* | | | Merge pull request #9401 from jdufresne/neStéphane Bidoul2021-01-011-3/+0
|\ \ \ \ | | | | | | | | | | Remove unnecessary __ne__ definitions
| * | | | Remove unnecessary __ne__ definitionsJon Dufresne2020-12-301-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unnecessary since dropping Python 2 support. In Python 3, `__ne__` defaults to the opposite of of `__eq__`. https://docs.python.org/3/reference/datamodel.html#object.__ne__ > For `__ne__()`, by default it delegates to `__eq__()` and inverts the > result unless it is `NotImplemented`.
* | | | | Replace compat.expanduser() with os.path.expanduser()Jon Dufresne2020-12-292-15/+2
|/ / / / | | | | | | | | | | | | | | | | The upstream bug has been fixed and released in all supported Python version: https://bugs.python.org/issue14768
* | | | Remove unnecessary "noqa" commentsJon Dufresne2020-12-282-5/+3
| | | |
* | | | Merge pull request #9382 from jdufresne/colorama-importPradyun Gedam2020-12-281-23/+3
|\ \ \ \ | | | | | | | | | | Remove outdated mypy workaround for colorama import
| * | | | Remove outdated mypy workaround for colorama importJon Dufresne2020-12-271-23/+3
| | | | |
* | | | | Remove unnecessary type override NamedTemporaryFileResultJon Dufresne2020-12-271-10/+4
|/ / / / | | | | | | | | | | | | | | | | | | | | The object returned by NamedTemporaryFile delegates all functions calls to the underlying file so can avoid the type override by relying on IO methods.
* | | | Remove unnecessary class FakeFileJon Dufresne2020-12-271-16/+0
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The class was being used in a single place, passed to csv.reader(). However, per the docs, csv.reader() can handle a list of str objects. https://docs.python.org/3/library/csv.html#csv.reader > csvfile can be any object which supports the iterator protocol and > returns a string each time its __next__() method is called — file > objects and list objects are both suitable.
* | | Cleanup: replace 'from urllib import xyz as urllib_xyz' with import urllib.xyzHugo van Kemenade2020-12-272-12/+11
| | |
* | | Merge pull request #9364 from jdufresne/oserrorPradyun Gedam2020-12-273-19/+13
|\ \ \ | | | | | | | | Use unified OSError and its subclasses
| * | | Use unified OSError and its subclassesJon Dufresne2020-12-263-19/+13
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Re-apply invalid metadata skipTzu-ping Chung2020-12-271-6/+2
|/ / | | | | | | | | | | Skip candidate not providing valid metadata This reverts commit 7165ab8cb9a0d6297b5a0dcd7d9a84350d0a0b3b.
* | Merge pull request #9352 from jdufresne/io-codecs-openPradyun Gedam2020-12-261-2/+1
|\ \ | | | | | | Replace io.open() and codecs.open() with builtin open()
| * | Replace io.open() and codecs.open() with builtin open()Jon Dufresne2020-12-251-2/+1
| | | | | | | | | | | | | | | In Python 3, these are functionally equivalent and share the same feature set.