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

Linter updates #8902

Merged
merged 3 commits into from
Sep 23, 2020
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: 'src/pip/_vendor/'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v3.2.0
hooks:
- id: check-builtin-literals
- id: check-added-large-files
Expand All @@ -17,7 +17,7 @@ repos:
exclude: .patch

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.1
rev: 3.8.3
hooks:
- id: flake8
additional_dependencies: [
Expand All @@ -27,7 +27,7 @@ repos:
exclude: tests/data

- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
rev: 5.5.3
hooks:
- id: isort
files: \.py$
Expand All @@ -44,7 +44,7 @@ repos:
args: ["--pretty", "-2"]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.5.1
rev: v1.6.0
hooks:
- id: python-no-log-warn
- id: python-no-eval
Expand All @@ -56,6 +56,6 @@ repos:
exclude: NEWS.rst

- repo: https://github.com/mgedmin/check-manifest
rev: '0.42'
rev: '0.43'
hooks:
- id: check-manifest
2 changes: 1 addition & 1 deletion docs/html/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ The big change in this release is to the pip dependency resolver
within pip.

Computers need to know the right order to install pieces of software
("to install `x`, you need to install `y` first"). So, when Python
("to install ``x``, you need to install ``y`` first"). So, when Python
programmers share software as packages, they have to precisely describe
those installation prerequisites, and pip needs to navigate tricky
situations where it's getting conflicting instructions. This new
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Optional, List
from typing import List, Optional


def main(args=None):
Expand Down
3 changes: 2 additions & 1 deletion src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

if MYPY_CHECK_RUNNING:
from types import TracebackType
from typing import Tuple, Set, Iterable, Optional, List, Type
from typing import Iterable, List, Optional, Set, Tuple, Type

from pip._internal.index.package_finder import PackageFinder

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pip._internal.utils.urls import path_to_url

if MYPY_CHECK_RUNNING:
from typing import Optional, Set, List, Any, Dict
from typing import Any, Dict, List, Optional, Set

from pip._vendor.packaging.tags import Tag

Expand Down
5 changes: 2 additions & 3 deletions src/pip/_internal/cli/base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@
from pip._internal.utils.virtualenv import running_under_virtualenv

if MYPY_CHECK_RUNNING:
from typing import List, Optional, Tuple, Any
from optparse import Values
from typing import Any, List, Optional, Tuple

from pip._internal.utils.temp_dir import (
from pip._internal.utils.temp_dir import \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch... shouldn't EOL escaping be banned?

TempDirectoryTypeRegistry as TempDirRegistry
)

__all__ = ['Command']

Expand Down
3 changes: 2 additions & 1 deletion src/pip/_internal/cli/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Any, Callable, Dict, Optional, Tuple
from optparse import OptionParser, Values
from typing import Any, Callable, Dict, Optional, Tuple

from pip._internal.cli.parser import ConfigOptionParser


Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/cli/command_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Iterator, ContextManager, TypeVar
from typing import ContextManager, Iterator, TypeVar

_T = TypeVar('_T', covariant=True)

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/cli/main_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Tuple, List
from typing import List, Tuple


__all__ = ["create_main_parser", "parse_command"]
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/cli/spinners.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Iterator, IO
from typing import IO, Iterator

logger = logging.getLogger(__name__)

Expand Down
1 change: 1 addition & 0 deletions src/pip/_internal/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

if MYPY_CHECK_RUNNING:
from typing import Any

from pip._internal.cli.base_command import Command


Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
logger = logging.getLogger(__name__)

if MYPY_CHECK_RUNNING:
from typing import List, Any
from optparse import Values
from typing import Any, List


class CheckCommand(Command):
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import List
from optparse import Values
from typing import List

BASE_COMPLETION = """
# pip {shell} completion start{script}# pip {shell} completion end
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import List, Any, Optional
from optparse import Values
from typing import Any, List, Optional

from pip._internal.configuration import Kind

Expand Down
5 changes: 3 additions & 2 deletions src/pip/_internal/commands/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from types import ModuleType
from typing import List, Optional, Dict
from optparse import Values
from types import ModuleType
from typing import Dict, List, Optional

from pip._internal.configuration import Configuration

logger = logging.getLogger(__name__)
Expand Down
6 changes: 4 additions & 2 deletions src/pip/_internal/commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import List
from optparse import Values
from typing import List


class HelpCommand(Command):
Expand All @@ -20,7 +20,9 @@ class HelpCommand(Command):
def run(self, options, args):
# type: (Values, List[str]) -> int
from pip._internal.commands import (
commands_dict, create_command, get_similar_commands,
commands_dict,
create_command,
get_similar_commands,
)

try:
Expand Down
5 changes: 3 additions & 2 deletions src/pip/_internal/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@

if MYPY_CHECK_RUNNING:
from optparse import Values
from typing import List, Set, Tuple, Iterator
from typing import Iterator, List, Set, Tuple

from pip._internal.network.session import PipSession
from pip._vendor.pkg_resources import Distribution

from pip._internal.network.session import PipSession

logger = logging.getLogger(__name__)


Expand Down
3 changes: 2 additions & 1 deletion src/pip/_internal/commands/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

if MYPY_CHECK_RUNNING:
from optparse import Values
from typing import List, Dict, Optional
from typing import Dict, List, Optional

from typing_extensions import TypedDict
TransformedHit = TypedDict(
'TransformedHit',
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

if MYPY_CHECK_RUNNING:
from optparse import Values
from typing import List, Dict, Iterator
from typing import Dict, Iterator, List

logger = logging.getLogger(__name__)

Expand Down
4 changes: 1 addition & 3 deletions src/pip/_internal/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import (
Any, Dict, Iterable, List, NewType, Optional, Tuple
)
from typing import Any, Dict, Iterable, List, NewType, Optional, Tuple

RawConfigParser = configparser.RawConfigParser # Shorthand
Kind = NewType("Kind", str)
Expand Down
3 changes: 2 additions & 1 deletion src/pip/_internal/distributions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from typing import Optional

from pip._vendor.pkg_resources import Distribution
from pip._internal.req import InstallRequirement

from pip._internal.index.package_finder import PackageFinder
from pip._internal.req import InstallRequirement


@add_metaclass(abc.ABCMeta)
Expand Down
1 change: 1 addition & 0 deletions src/pip/_internal/distributions/installed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Optional

from pip._vendor.pkg_resources import Distribution

from pip._internal.index.package_finder import PackageFinder


Expand Down
1 change: 1 addition & 0 deletions src/pip/_internal/distributions/sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Set, Tuple

from pip._vendor.pkg_resources import Distribution

from pip._internal.index.package_finder import PackageFinder


Expand Down
1 change: 1 addition & 0 deletions src/pip/_internal/distributions/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

if MYPY_CHECK_RUNNING:
from pip._vendor.pkg_resources import Distribution

from pip._internal.index.package_finder import PackageFinder


Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Any, Optional, List, Dict, Text
from typing import Any, Dict, List, Optional, Text

from pip._vendor.pkg_resources import Distribution
from pip._vendor.requests.models import Response, Request
from pip._vendor.requests.models import Request, Response
from pip._vendor.six import PY3
from pip._vendor.six.moves import configparser

Expand Down
14 changes: 11 additions & 3 deletions src/pip/_internal/index/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@
from pip._internal.vcs import is_url, vcs

if MYPY_CHECK_RUNNING:
import xml.etree.ElementTree
from optparse import Values
from typing import (
Callable, Iterable, List, MutableMapping, Optional,
Protocol, Sequence, Tuple, TypeVar, Union,
Callable,
Iterable,
List,
MutableMapping,
Optional,
Protocol,
Sequence,
Tuple,
TypeVar,
Union,
)
import xml.etree.ElementTree

from pip._vendor.requests import Response

Expand Down
9 changes: 8 additions & 1 deletion src/pip/_internal/index/package_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@

if MYPY_CHECK_RUNNING:
from typing import (
FrozenSet, Iterable, List, Optional, Set, Text, Tuple, Union,
FrozenSet,
Iterable,
List,
Optional,
Set,
Text,
Tuple,
Union,
)

from pip._vendor.packaging.tags import Tag
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
from pip._internal.utils.virtualenv import running_under_virtualenv

if MYPY_CHECK_RUNNING:
from typing import Dict, List, Optional, Union

from distutils.cmd import Command as DistutilsCommand
from typing import Dict, List, Optional, Union


# Application Directories
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Optional, List
from typing import List, Optional


def main(args=None):
Expand Down
1 change: 1 addition & 0 deletions src/pip/_internal/models/candidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

if MYPY_CHECK_RUNNING:
from pip._vendor.packaging.version import _BaseVersion

from pip._internal.models.link import Link


Expand Down
4 changes: 1 addition & 3 deletions src/pip/_internal/models/direct_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import (
Any, Dict, Iterable, Optional, Type, TypeVar, Union
)
from typing import Any, Dict, Iterable, Optional, Type, TypeVar, Union

T = TypeVar("T")

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/models/format_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Optional, Set, FrozenSet
from typing import FrozenSet, Optional, Set


class FormatControl(object):
Expand Down
1 change: 1 addition & 0 deletions src/pip/_internal/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

if MYPY_CHECK_RUNNING:
from typing import Optional, Text, Tuple, Union

from pip._internal.index.collector import HTMLPage
from pip._internal.utils.hashes import Hashes

Expand Down
Loading