Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip line number annotations #1075

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Now, run ``pip-compile requirements.in``:
# pip-compile requirements.in
#
asgiref==3.2.3 # via django
django==3.0.3 # via -r requirements.in (line 1)
django==3.0.3 # via -r requirements.in
pytz==2019.3 # via django
sqlparse==0.3.0 # via django

Expand Down Expand Up @@ -146,7 +146,7 @@ version 8.0, ``pip-compile`` offers ``--generate-hashes`` flag:
django==3.0.3 \
--hash=sha256:2f1ba1db8648484dd5c238fb62504777b7ad090c81c5f1fd8d5eb5ec21b5f283 \
--hash=sha256:c91c91a7ad6ef67a874a4f76f58ba534f9208412692a840e1d125eb5c279cb0a \
# via -r requirements.in (line 1)
# via -r requirements.in
pytz==2019.3 \
--hash=sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d \
--hash=sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be \
Expand Down Expand Up @@ -221,7 +221,7 @@ generated at the top of requirements files by setting the
# ./pipcompilewrapper
#
asgiref==3.2.3 # via django
django==3.0.3 # via -r requirements.in (line 1)
django==3.0.3 # via -r requirements.in
pytz==2019.3 # via django
sqlparse==0.3.0 # via django

Expand Down Expand Up @@ -262,7 +262,7 @@ First, compile ``requirements.txt`` as usual:
#
# pip-compile
#
django==2.1.15 # via -r requirements.in (line 1)
django==2.1.15 # via -r requirements.in
pytz==2019.3 # via django


Expand All @@ -278,9 +278,9 @@ a constraint:
#
# pip-compile dev-requirements.in
#
django-debug-toolbar==2.2 # via -r dev-requirements.in (line 2)
django==2.1.15 # via -c requirements.txt (line 7), django-debug-toolbar
pytz==2019.3 # via -c requirements.txt (line 8), django
django-debug-toolbar==2.2 # via -r dev-requirements.in
django==2.1.15 # via -c requirements.txt, django-debug-toolbar
pytz==2019.3 # via -c requirements.txt, django
sqlparse==0.3.0 # via django-debug-toolbar

As you can see above, even though a ``2.2`` release of Django is available, the
Expand Down
6 changes: 5 additions & 1 deletion piptools/writer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import unicode_literals

import os
import re
from itertools import chain

import six
Expand Down Expand Up @@ -38,9 +39,12 @@
)


strip_comes_from_line_re = re.compile(r" \(line \d+\)$")


def _comes_from_as_string(ireq):
if isinstance(ireq.comes_from, six.string_types):
return ireq.comes_from
return strip_comes_from_line_re.sub("", ireq.comes_from)
return key_from_ireq(ireq.comes_from)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def test_multiple_input_files_without_output_file(runner):
(
"--annotate",
"small-fake-a==0.1 "
"# via -c constraints.txt (line 1), small-fake-with-deps\n",
"# via -c constraints.txt, small-fake-with-deps\n",
),
("--no-annotate", "small-fake-a==0.1\n"),
],
Expand Down