Skip to content

Commit 618e975

Browse files
Jacob Kimchrahunt
Jacob Kim
authored andcommitted
Respect docstring conventions (#7230)
Respect PEP 257 -- Docstring Conventions in wheel.py
1 parent 8dbf846 commit 618e975

File tree

2 files changed

+19
-35
lines changed

2 files changed

+19
-35
lines changed

news/7230.trivial

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change ``pip._internal.wheel`` to respect docstring conventions.

src/pip/_internal/wheel.py

+18-35
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Support for installing and building the "wheel" binary package format.
1+
"""Support for installing and building the "wheel" binary package format.
32
"""
43

54
# The following comment should be removed at some point in the future.
@@ -118,8 +117,7 @@ def open_for_csv(name, mode):
118117

119118
def replace_python_tag(wheelname, new_tag):
120119
# type: (str, str) -> str
121-
"""Replace the Python tag in a wheel file name with a new value.
122-
"""
120+
"""Replace the Python tag in a wheel file name with a new value."""
123121
parts = wheelname.split('-')
124122
parts[-3] = new_tag
125123
return '-'.join(parts)
@@ -128,7 +126,8 @@ def replace_python_tag(wheelname, new_tag):
128126
def fix_script(path):
129127
# type: (str) -> Optional[bool]
130128
"""Replace #!python with #!/path/to/python
131-
Return True if file was changed."""
129+
Return True if file was changed.
130+
"""
132131
# XXX RECORD hashes will need to be updated
133132
if os.path.isfile(path):
134133
with open(path, 'rb') as script:
@@ -151,9 +150,7 @@ def fix_script(path):
151150

152151
def root_is_purelib(name, wheeldir):
153152
# type: (str, str) -> bool
154-
"""
155-
Return True if the extracted wheel in wheeldir should go into purelib.
156-
"""
153+
"""True if the extracted wheel in wheeldir should go into purelib."""
157154
name_folded = name.replace("-", "_")
158155
for item in os.listdir(wheeldir):
159156
match = dist_info_re.match(item)
@@ -188,8 +185,9 @@ def get_entrypoints(filename):
188185
gui = entry_points.get('gui_scripts', {})
189186

190187
def _split_ep(s):
191-
"""get the string representation of EntryPoint, remove space and split
192-
on '='"""
188+
"""get the string representation of EntryPoint,
189+
remove space and split on '='
190+
"""
193191
return str(s).replace(" ", "").split("=")
194192

195193
# convert the EntryPoint objects into strings with module:function
@@ -201,7 +199,6 @@ def _split_ep(s):
201199
def message_about_scripts_not_on_PATH(scripts):
202200
# type: (Sequence[str]) -> Optional[str]
203201
"""Determine if any scripts are not on PATH and format a warning.
204-
205202
Returns a warning message if one or more scripts are not on PATH,
206203
otherwise None.
207204
"""
@@ -261,8 +258,7 @@ def message_about_scripts_not_on_PATH(scripts):
261258

262259
def sorted_outrows(outrows):
263260
# type: (Iterable[InstalledCSVRow]) -> List[InstalledCSVRow]
264-
"""
265-
Return the given rows of a RECORD file in sorted order.
261+
"""Return the given rows of a RECORD file in sorted order.
266262
267263
Each row is a 3-tuple (path, hash, size) and corresponds to a record of
268264
a RECORD file (see PEP 376 and PEP 427 for details). For the rows
@@ -644,9 +640,7 @@ def is_entrypoint_wrapper(name):
644640

645641
def wheel_version(source_dir):
646642
# type: (Optional[str]) -> Optional[Tuple[int, ...]]
647-
"""
648-
Return the Wheel-Version of an extracted wheel, if possible.
649-
643+
"""Return the Wheel-Version of an extracted wheel, if possible.
650644
Otherwise, return None if we couldn't parse / extract it.
651645
"""
652646
try:
@@ -664,8 +658,7 @@ def wheel_version(source_dir):
664658

665659
def check_compatibility(version, name):
666660
# type: (Optional[Tuple[int, ...]], str) -> None
667-
"""
668-
Raises errors or warns if called with an incompatible Wheel-Version.
661+
"""Raises errors or warns if called with an incompatible Wheel-Version.
669662
670663
Pip should refuse to install a Wheel-Version that's a major series
671664
ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when
@@ -694,8 +687,7 @@ def check_compatibility(version, name):
694687

695688
def format_tag(file_tag):
696689
# type: (Tuple[str, ...]) -> str
697-
"""
698-
Format three tags in the form "<python_tag>-<abi_tag>-<platform_tag>".
690+
"""Format three tags in the form "<python_tag>-<abi_tag>-<platform_tag>".
699691
700692
:param file_tag: A 3-tuple of tags (python_tag, abi_tag, platform_tag).
701693
"""
@@ -743,15 +735,12 @@ def __init__(self, filename):
743735

744736
def get_formatted_file_tags(self):
745737
# type: () -> List[str]
746-
"""
747-
Return the wheel's tags as a sorted list of strings.
748-
"""
738+
"""Return the wheel's tags as a sorted list of strings."""
749739
return sorted(format_tag(tag) for tag in self.file_tags)
750740

751741
def support_index_min(self, tags):
752742
# type: (List[Pep425Tag]) -> int
753-
"""
754-
Return the lowest index that one of the wheel's file_tag combinations
743+
"""Return the lowest index that one of the wheel's file_tag combinations
755744
achieves in the given list of supported tags.
756745
757746
For example, if there are 8 supported tags and one of the file tags
@@ -767,8 +756,7 @@ def support_index_min(self, tags):
767756

768757
def supported(self, tags):
769758
# type: (List[Pep425Tag]) -> bool
770-
"""
771-
Return whether the wheel is compatible with one of the given tags.
759+
"""Return whether the wheel is compatible with one of the given tags.
772760
773761
:param tags: the PEP 425 tags to check the wheel against.
774762
"""
@@ -791,8 +779,7 @@ def should_use_ephemeral_cache(
791779
check_binary_allowed, # type: BinaryAllowedPredicate
792780
):
793781
# type: (...) -> Optional[bool]
794-
"""
795-
Return whether to build an InstallRequirement object using the
782+
"""Return whether to build an InstallRequirement object using the
796783
ephemeral cache.
797784
798785
:param cache_available: whether a cache directory is available for the
@@ -847,9 +834,7 @@ def format_command_result(
847834
command_output, # type: str
848835
):
849836
# type: (...) -> str
850-
"""
851-
Format command information for logging.
852-
"""
837+
"""Format command information for logging."""
853838
command_desc = format_command_args(command_args)
854839
text = 'Command arguments: {}\n'.format(command_desc)
855840

@@ -873,9 +858,7 @@ def get_legacy_build_wheel_path(
873858
command_output, # type: str
874859
):
875860
# type: (...) -> Optional[str]
876-
"""
877-
Return the path to the wheel in the temporary build directory.
878-
"""
861+
"""Return the path to the wheel in the temporary build directory."""
879862
# Sort for determinism.
880863
names = sorted(names)
881864
if not names:

0 commit comments

Comments
 (0)