Repository: adamchainz/pip-lock

Issue:
Crashes on lines providing arguments to pip
For example `--find-links`

Discussion:

Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index ed86591..e15c981 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -2,6 +2,9 @@
 History
 =======
 
+* Fix to ignore lines that represent arguments to pip, such as
+  ``--find-links``.
+
 2.2.0 (2020-12-13)
 ------------------
 
diff --git a/src/pip_lock.py b/src/pip_lock.py
index 38edddf..a050b3f 100644
--- a/src/pip_lock.py
+++ b/src/pip_lock.py
@@ -27,7 +27,7 @@ def get_package_versions(lines, ignore_external_and_at=False):
     for line in lines:
         line = line.strip()
 
-        if len(line) == 0 or line.startswith("#") or line.startswith("-r "):
+        if len(line) == 0 or line.startswith(("#", "-")):
             continue
 
         if line.startswith("https://"):


Test patch:
diff --git a/tests/test_pip_lock.py b/tests/test_pip_lock.py
index cca27a5..7dde0c4 100644
--- a/tests/test_pip_lock.py
+++ b/tests/test_pip_lock.py
@@ -49,6 +49,9 @@ class TestGetPackageVersion:
     def test_ignore_includes(self):
         assert get_package_versions(["-r example.txt"]) == {}
 
+    def test_ignore_arguments(self):
+        assert get_package_versions(["--find-links file:./wheels"]) == {}
+
     def test_ignore_urls(self):
         assert get_package_versions(["https://www.google.com"]) == {}