未验证 提交 5e072e2e 编写于 作者: T Tzu-ping Chung 提交者: GitHub

Merge pull request #9773 from sbidoul/fix-pre-commit-ci

......@@ -43,7 +43,7 @@ jobs:
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.0
with:
extra_args: --hook-stage=manual
extra_args: --all-files --hook-stage=manual
packaging:
name: packaging
......
......@@ -5,7 +5,7 @@ import pathlib
import re
import sys
from textwrap import dedent
from typing import Iterable, List, Optional
from typing import Iterable, Iterator, List, Optional
from docutils import nodes, statemachine
from docutils.parsers import rst
......@@ -20,7 +20,9 @@ from pip._internal.req.req_file import SUPPORTED_OPTIONS
class PipNewsInclude(rst.Directive):
required_arguments = 1
def _is_version_section_title_underline(self, prev, curr):
def _is_version_section_title_underline(
self, prev: Optional[str], curr: str
) -> bool:
"""Find a ==== line that marks the version section title."""
if prev is None:
return False
......@@ -30,7 +32,7 @@ class PipNewsInclude(rst.Directive):
return False
return True
def _iter_lines_with_refs(self, lines):
def _iter_lines_with_refs(self, lines: Iterable[str]) -> Iterator[str]:
"""Transform the input lines to add a ref before each section title.
This is done by looking one line ahead and locate a title's underline,
......@@ -44,6 +46,7 @@ class PipNewsInclude(rst.Directive):
for line in lines:
# Transform the previous line to include an explicit ref.
if self._is_version_section_title_underline(prev, line):
assert prev is not None
vref = prev.split(None, 1)[0].replace(".", "-")
yield f".. _`v{vref}`:"
yield "" # Empty line between ref and the title.
......@@ -53,7 +56,7 @@ class PipNewsInclude(rst.Directive):
if prev is not None:
yield prev
def run(self):
def run(self) -> List[nodes.Node]:
source = self.state_machine.input_lines.source(
self.lineno - self.state_machine.input_offset - 1,
)
......
Improve performance when picking the best file from indexes during `pip install`.
Improve performance when picking the best file from indexes during ``pip install``.
......@@ -2,7 +2,7 @@
name that have meaning.
"""
import re
from typing import Dict, List
from typing import Dict, Iterable, List
from pip._vendor.packaging.tags import Tag
......@@ -82,7 +82,9 @@ class Wheel:
:raises ValueError: If none of the wheel's file tags match one of
the supported tags.
"""
return min(tag_to_priority[tag] for tag in self.file_tags if tag in tag_to_priority)
return min(
tag_to_priority[tag] for tag in self.file_tags if tag in tag_to_priority
)
def supported(self, tags):
# type: (Iterable[Tag]) -> bool
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册