From a47803f0bd5744213ac24e793add0f805bd69d69 Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Sun, 22 Sep 2019 18:49:34 -0400 Subject: [PATCH] Remove unused RequirementSet.require_hashes --- src/pip/_internal/cli/req_command.py | 3 --- src/pip/_internal/commands/download.py | 4 +--- src/pip/_internal/commands/install.py | 1 - src/pip/_internal/commands/wheel.py | 4 +--- src/pip/_internal/req/req_set.py | 5 ++--- tests/unit/test_req.py | 10 +++++----- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/pip/_internal/cli/req_command.py b/src/pip/_internal/cli/req_command.py index c456f54ade7..ee6e0915fa9 100644 --- a/src/pip/_internal/cli/req_command.py +++ b/src/pip/_internal/cli/req_command.py @@ -253,9 +253,6 @@ def populate_requirement_set( use_pep517=options.use_pep517): req_to_add.is_direct = True requirement_set.add_requirement(req_to_add) - # If --require-hashes was a line in a requirements file, tell - # RequirementSet about it: - requirement_set.require_hashes = options.require_hashes if not (args or options.editables or options.requirements): opts = {'name': self.name} diff --git a/src/pip/_internal/commands/download.py b/src/pip/_internal/commands/download.py index 4712a894d8a..c005d36f9e5 100644 --- a/src/pip/_internal/commands/download.py +++ b/src/pip/_internal/commands/download.py @@ -112,9 +112,7 @@ def run(self, options, args): options.build_dir, delete=build_delete, kind="download" ) as directory: - requirement_set = RequirementSet( - require_hashes=options.require_hashes, - ) + requirement_set = RequirementSet() self.populate_requirement_set( requirement_set, args, diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py index a14b1b38f45..8db8e311595 100644 --- a/src/pip/_internal/commands/install.py +++ b/src/pip/_internal/commands/install.py @@ -351,7 +351,6 @@ def run(self, options, args): options.build_dir, delete=build_delete, kind="install" ) as directory: requirement_set = RequirementSet( - require_hashes=options.require_hashes, check_supported_wheels=not options.target_dir, ) diff --git a/src/pip/_internal/commands/wheel.py b/src/pip/_internal/commands/wheel.py index b95732b0ce4..5f932b10b7b 100644 --- a/src/pip/_internal/commands/wheel.py +++ b/src/pip/_internal/commands/wheel.py @@ -125,9 +125,7 @@ def run(self, options, args): options.build_dir, delete=build_delete, kind="wheel" ) as directory: - requirement_set = RequirementSet( - require_hashes=options.require_hashes, - ) + requirement_set = RequirementSet() try: self.populate_requirement_set( diff --git a/src/pip/_internal/req/req_set.py b/src/pip/_internal/req/req_set.py index b34a2bb11b8..f1ad97fc768 100644 --- a/src/pip/_internal/req/req_set.py +++ b/src/pip/_internal/req/req_set.py @@ -24,13 +24,12 @@ class RequirementSet(object): - def __init__(self, require_hashes=False, check_supported_wheels=True): - # type: (bool, bool) -> None + def __init__(self, check_supported_wheels=True): + # type: (bool) -> None """Create a RequirementSet. """ self.requirements = OrderedDict() # type: Dict[str, InstallRequirement] # noqa: E501 - self.require_hashes = require_hashes self.check_supported_wheels = check_supported_wheels self.unnamed_requirements = [] # type: List[InstallRequirement] diff --git a/tests/unit/test_req.py b/tests/unit/test_req.py index 68f41b24957..3f3e403f873 100644 --- a/tests/unit/test_req.py +++ b/tests/unit/test_req.py @@ -172,7 +172,7 @@ def test_missing_hash_with_require_hashes(self, data): """Setting --require-hashes explicitly should raise errors if hashes are missing. """ - reqset = RequirementSet(require_hashes=True) + reqset = RequirementSet() reqset.add_requirement(get_processed_req_from_line( 'simple==1.0', lineno=1 )) @@ -194,7 +194,7 @@ def test_missing_hash_with_require_hashes_in_reqs_file(self, data, tmpdir): """--require-hashes in a requirements file should make its way to the RequirementSet. """ - req_set = RequirementSet(require_hashes=False) + req_set = RequirementSet() finder = make_test_finder(find_links=[data.find_links]) session = finder._link_collector.session command = create_command('install') @@ -203,7 +203,7 @@ def test_missing_hash_with_require_hashes_in_reqs_file(self, data, tmpdir): command.populate_requirement_set( req_set, args, options, finder, session, wheel_cache=None, ) - assert req_set.require_hashes + assert options.require_hashes def test_unsupported_hashes(self, data): """VCS and dir links should raise errors when --require-hashes is @@ -213,7 +213,7 @@ def test_unsupported_hashes(self, data): should trump the presence or absence of a hash. """ - reqset = RequirementSet(require_hashes=True) + reqset = RequirementSet() reqset.add_requirement(get_processed_req_from_line( 'git+git://github.com/pypa/pip-test-package --hash=sha256:123', lineno=1, @@ -272,7 +272,7 @@ def test_hash_mismatch(self, data): """A hash mismatch should raise an error.""" file_url = path_to_url( (data.packages / 'simple-1.0.tar.gz').abspath) - reqset = RequirementSet(require_hashes=True) + reqset = RequirementSet() reqset.add_requirement(get_processed_req_from_line( '%s --hash=sha256:badbad' % file_url, lineno=1, ))