Commit Graph

140 Commits

Author SHA1 Message Date
Jon Dufresne 004b2cf9a8 Remove unused utility function consume()
Unused since e706af20fe.
2021-01-01 16:07:53 -08:00
Jon Dufresne 5150129f6b Replace compat.expanduser() with os.path.expanduser()
The upstream bug has been fixed and released in all supported Python
version: https://bugs.python.org/issue14768
2020-12-29 08:15:55 -08:00
Jon Dufresne b78f71216f Remove unnecessary "noqa" comments 2020-12-28 18:19:09 -08:00
Jon Dufresne 8a9fea7434 Remove unnecessary class FakeFile
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.
2020-12-27 09:26:15 -08: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
Pradyun Gedam 86afa89043
Merge pull request #9361 from jdufresne/f-strings
Use f-strings for simple string formatting
2020-12-26 10:24:18 +00:00
Jon Dufresne cdcf74fb8e Use f-strings for simple string formatting
Use pyupgrade to convert simple string formatting to use f-string
syntax. pyupgrade is intentionally timid and will not create an f-string
if it would make the expression longer or if the substitution parameters
are anything but simple names or dotted names.
2020-12-25 16:21:20 -08:00
Jon Dufresne 09b3d3a50b Remove object from class definitions
Unnecessary since dropping Python 2 support. In Python 3, all classes
are new style classes.
2020-12-25 15:48:11 -08:00
Jon Dufresne 5e11687cbd Replace typing.Text with str
Using typing.Text is unnecessary since dropping Python 2 support.

In Python 3, typing.Text is a simple alias of str. It exists as a
backward compatibility shim for Python 2.
2020-12-24 16:40:55 -08:00
Jon Dufresne f32adaf09b Remove __future__ imports
Unnecessary since dropping Python 2.
2020-12-24 08:38:09 -08:00
Hugo van Kemenade 817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
Tzu-ping Chung 94fbb6cf78 Only do the ensure_text() dance on Windows
POSIX is problematic when the environment is not configured properly.
2020-10-27 21:40:39 +08:00
Pradyun Gedam 58c594c06b
Prepare isort for black 2020-09-23 21:47:47 +05:30
Pradyun Gedam 25ab172b55
Update linter: isort 2020-09-23 19:52:28 +05:30
Tzu-ping Chung 8491ce7723 Refactor and clarify get_distribution() behavior
The call to get_installed_distributions() now passes all flags
excplicitly so they are more obvious and less likely to be misunderstood
in the future. The behavior also documented in the function docstring.

The search_distribution() helper function is renamed with a leading
underscore to make it clear that it is intended as a helper function to
get_distribution().
2020-08-05 03:07:07 +08:00
Tzu-ping Chung e459763d81 Also look for non-local when searching for dists
This matches the behavior of pkg_resources.get_distribution(), which
this function intends to replace.
2020-08-05 03:07:07 +08:00
Chris Hunt d241f0d30a Add partition from itertools recipes
From https://docs.python.org/3/library/itertools.html,
adapted for Python 2 and with types added.

This will be used in the next commit.
2020-07-09 18:23:17 -04:00
Devesh Kumar Singh fb05730898 Align write_output types with logger.info 2020-07-07 15:23:05 +05:30
Devesh Kumar Singh 6c1030ca95 Fix comment order for retrying module 2020-07-06 19:17:26 +05:30
Devesh Kumar Singh 04fedfe53c Create custom get_distribution function 2020-07-06 13:42:05 +05:30
Devesh Kumar Singh 021eddcb70 Remove try/catch and use next 2020-06-10 00:36:03 +05:30
Devesh Kumar Singh 76a130105c Fix src/pip with flake8-bugbear 2020-06-10 00:36:03 +05:30
Devesh Kumar Singh ae2f9c645a Remove unused cached_property 2020-06-05 22:11:15 +05:30
Tzu-ping Chung dd50a03f10 Use unicode for filesystem stuff on Python 2 2020-05-19 16:03:51 +08:00
Tzu-ping Chung dc4171c213 Python 2 works but not tested 2020-05-19 16:03:51 +08:00
Devesh Kumar Singh 60f00b837a Upgrade flake8 to 3.8.1
Co-Authored-By: Anthony Sottile <asottile@umich.edu>
2020-05-18 21:58:26 +05:30
Nguyễn Gia Phong 26b76f6f11 Move tabulate to utils.misc and test it 2020-04-07 17:35:47 +07:00
Jason R. Coombs 3511d3d493 Convert the remaining '%' formatters to '.format'. Fixes #6973. 2020-03-06 12:43:03 -05:00
Pradyun Gedam cdae7277ef
Merge pull request #7596 from uranusjr/6446-link-url-quoting
Fix incorrect quoting Link.url
2020-02-14 16:00:43 +05:30
Deepak Sharma d31cf696e8 string_formatting 2020-01-30 20:33:00 +05:30
Tzu-ping Chung cdd7821d92 Fix incorrect quoting Link.url
Cherry-picked manually from atugushev:fix-issue-6446.

Co-Authored-By: Albert Tugushev <albert@tugushev.ru>
2020-01-14 16:12:11 +08:00
Chris Hunt 3fac3d74ac Inline _make_build_dir in InstallRequirement
This untested function was only used in one place. Inlining it makes it
easier to see the symmetry between the writing of the delete marker file
in `ensure_build_location` and checking for it in
`remove_temporary_source`.
2020-01-08 20:34:28 -05:00
Pradyun Gedam 6c515125c2
Merge pradyunsg:revert/6864 into master (#7557)
Revert addition of un-suffixed pip CLI entry points for invocation check on Windows
2020-01-07 08:16:38 +00:00
Pradyun Gedam d9d801f818
Drop no-suffix checks for pip-from-PATH 2020-01-06 19:29:56 +05:30
Stéphane Bidoul (ACSONE) 3ae13f7d28
Move is_wheel_installed to utils 2020-01-05 23:52:40 +01:00
Maxim Kurnikov 38fd95aa6a update to mypy==0.750 2019-12-12 11:08:36 +01:00
BorisZZZ 4659fe16bd #6426 Cannot install packages on Docker in Ubuntu in WSL (Windows). (#6427) 2019-11-28 12:05:17 +08:00
Xavier Fernandez 95576102c5
Tweak format_size utility function to include a space (#7399) 2019-11-25 22:09:10 +01:00
Pradyun Gedam 898d105649
Clean up distutils_scheme types (#7300) 2019-11-06 12:02:01 +05:30
Chris Hunt 912f5763c6 Move utils.misc.cast to avoid circular import 2019-11-04 20:16:36 -05:00
Pradyun Gedam 647d30ec77
Move hash_file to utils.misc
Why: Allows for better code reuse, without introducing dependency
between wheel->wheel_builder.
2019-11-04 11:51:08 +05:30
Krishna Oza 74972037b5 Simplify an interestingly written conditional (#7161) 2019-10-08 12:52:00 +05:30
Emil Burzo 7e50674393 extract function to misc 2019-10-01 18:55:13 +03:00
Pradyun Gedam d1bfeec18a
Move subprocessing related utilities to utils.subprocess 2019-09-30 11:15:06 +05:30
Maxim Kurnikov 3692097cca add per-file disallow_untyped_defs=False, and set it to True globally 2019-09-29 23:31:15 +02:00
Chris Jerdonek 0435316fde Move path_to_url() to utils/urls.py. 2019-09-24 02:01:52 -07:00
Chris Hunt 5656364112 Move supporting functions to utils.unpacking. 2019-09-17 23:40:02 -04:00
Chris Hunt 6a8b47d20b Move file type info to utils.filetypes. 2019-09-17 23:40:02 -04:00
Chris Hunt 6a5bd723ec Move unpack_* from utils.misc to utils.unpacking. 2019-09-17 23:40:02 -04:00