Skip to content

Commit

Permalink
Round of ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Aug 24, 2024
1 parent 8bf09c1 commit b44f3b4
Show file tree
Hide file tree
Showing 53 changed files with 92 additions and 115 deletions.
3 changes: 1 addition & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Automation using nox.
"""
"""Automation using nox."""

import argparse
import glob
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Build Environment used for isolation during sdist building
"""
"""Build Environment used for isolation during sdist building"""

import logging
import os
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Cache Management
"""
"""Cache Management"""

import hashlib
import json
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""Subpackage containing all of pip's command line interface related code
"""
"""Subpackage containing all of pip's command line interface related code"""

# This file intentionally does not import submodules
3 changes: 1 addition & 2 deletions src/pip/_internal/cli/autocompletion.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Logic that powers autocompletion installed by ``pip completion``.
"""
"""Logic that powers autocompletion installed by ``pip completion``."""

import optparse
import os
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Primary application entrypoint.
"""
"""Primary application entrypoint."""

import locale
import logging
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/cli/main_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""A single place for constructing and exposing the main parser
"""
"""A single place for constructing and exposing the main parser"""

import os
import subprocess
Expand Down
5 changes: 3 additions & 2 deletions src/pip/_internal/commands/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ def add_options(self) -> None:
dest="freeze_all",
action="store_true",
help=(
"Do not skip these packages in the output:"
" {}".format(", ".join(_dev_pkgs()))
"Do not skip these packages in the output:" " {}".format(
", ".join(_dev_pkgs())
)
),
)
self.cmd_opts.add_option(
Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ def run(self, options: Values, args: List[str]) -> int:
options.target_dir = os.path.abspath(options.target_dir)
if (
# fmt: off
os.path.exists(options.target_dir) and
not os.path.isdir(options.target_dir)
os.path.exists(options.target_dir)
and not os.path.isdir(options.target_dir)
# fmt: on
):
raise CommandError(
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/index/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
"""Index interaction code
"""
"""Index interaction code"""
3 changes: 2 additions & 1 deletion src/pip/_internal/metadata/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def sanitise_header(h: Union[Header, str]) -> str:
key = json_name(field)
if multi:
value: Union[str, List[str]] = [
sanitise_header(v) for v in msg.get_all(field) # type: ignore
sanitise_header(v)
for v in msg.get_all(field) # type: ignore
]
else:
value = sanitise_header(msg.get(field)) # type: ignore
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
"""A package that contains models that represent entities.
"""
"""A package that contains models that represent entities."""
2 changes: 1 addition & 1 deletion src/pip/_internal/models/direct_url.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" PEP 610 """
"""PEP 610"""

import json
import re
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/network/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
"""Contains purely network-related utilities.
"""
"""Contains purely network-related utilities."""
3 changes: 1 addition & 2 deletions src/pip/_internal/network/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""HTTP cache implementation.
"""
"""HTTP cache implementation."""

import os
from contextlib import contextmanager
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/network/download.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Download files with progress indicators.
"""
"""Download files with progress indicators."""

import email.message
import logging
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/network/xmlrpc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""xmlrpclib.Transport implementation
"""
"""xmlrpclib.Transport implementation"""

import logging
import urllib.parse
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/operations/build/metadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Metadata generation logic for source distributions.
"""
"""Metadata generation logic for source distributions."""

import os

Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/operations/build/metadata_editable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Metadata generation logic for source distributions.
"""
"""Metadata generation logic for source distributions."""

import os

Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/operations/build/metadata_legacy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Metadata generation logic for legacy source distributions.
"""
"""Metadata generation logic for legacy source distributions."""

import logging
import os
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/operations/check.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Validation of dependencies of packages
"""
"""Validation of dependencies of packages"""

import logging
from contextlib import suppress
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/operations/install/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
"""For modules related to installing packages.
"""
"""For modules related to installing packages."""
3 changes: 1 addition & 2 deletions src/pip/_internal/operations/install/editable_legacy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Legacy editable installation process, i.e. `setup.py develop`.
"""
"""Legacy editable installation process, i.e. `setup.py develop`."""

import logging
from typing import Optional, Sequence
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/operations/install/wheel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Support for installing and building the "wheel" binary package format.
"""
"""Support for installing and building the "wheel" binary package format."""

import collections
import compileall
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Prepares a distribution for installation
"""
"""Prepares a distribution for installation"""

# The following comment should be removed at some point in the future.
# mypy: strict-optional=False
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/req/req_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _script_names(


def _unique(
fn: Callable[..., Generator[Any, None, None]]
fn: Callable[..., Generator[Any, None, None]],
) -> Callable[..., Generator[Any, None, None]]:
@functools.wraps(fn)
def unique(*args: Any, **kw: Any) -> Generator[Any, None, None]:
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/utils/compatibility_tags.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Generate and work with PEP 425 Compatibility Tags.
"""
"""Generate and work with PEP 425 Compatibility Tags."""

import re
from typing import List, Optional, Tuple
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/utils/datetime.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""For when pip wants to check the date or time.
"""
"""For when pip wants to check the date or time."""

import datetime

Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/utils/filetypes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Filetype information.
"""
"""Filetype information."""

from typing import Tuple

Expand Down
1 change: 0 additions & 1 deletion src/pip/_internal/utils/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def retry(
"""

def wrapper(func: Callable[P, T]) -> Callable[P, T]:

@functools.wraps(func)
def retry_wrapped(*args: P.args, **kwargs: P.kwargs) -> T:
# The performance counter is monotonic on all platforms we care
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/utils/unpacking.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Utilities related archives.
"""
"""Utilities related archives."""

import logging
import os
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/utils/wheel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Support functions for working with wheel files.
"""
"""Support functions for working with wheel files."""

import logging
from email.message import Message
Expand Down
3 changes: 1 addition & 2 deletions src/pip/_internal/wheel_builder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Orchestrator for building wheels from InstallRequirements.
"""
"""Orchestrator for building wheels from InstallRequirements."""

import logging
import os.path
Expand Down
3 changes: 1 addition & 2 deletions tests/functional/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Basic CLI functionality checks.
"""
"""Basic CLI functionality checks."""

import subprocess
import sys
Expand Down
7 changes: 2 additions & 5 deletions tests/functional/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_completion_alone(autocomplete_script: PipTestEnvironment) -> None:
assert (
"ERROR: You must pass --bash or --fish or --powershell or --zsh"
in result.stderr
), ("completion alone failed -- " + result.stderr)
), "completion alone failed -- " + result.stderr


def test_completion_for_un_snippet(autocomplete: DoAutocomplete) -> None:
Expand Down Expand Up @@ -263,10 +263,7 @@ def test_completion_files_after_option(
), "autocomplete function could not complete <dir> after options in command"
assert not any(
out in res.stdout for out in (os.path.join("REPLAY", ""), "README.txt")
), (
"autocomplete function completed <file> or <dir> that "
"should not be completed"
)
), "autocomplete function completed <file> or <dir> that " "should not be completed"
if sys.platform != "win32":
return
assert (
Expand Down
3 changes: 1 addition & 2 deletions tests/functional/test_configuration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Tests for the config command
"""
"""Tests for the config command"""

import re
import textwrap
Expand Down
5 changes: 1 addition & 4 deletions tests/functional/test_install_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ def test_install_user_conflict_in_usersite(
dist_info_folder = script.user_site / "INITools-0.1.dist-info"
initools_v3_file = (
# file only in 0.3
script.base_path
/ script.user_site
/ "initools"
/ "configparser.py"
script.base_path / script.user_site / "initools" / "configparser.py"
)
result2.did_create(dist_info_folder)
assert not isfile(initools_v3_file), initools_v3_file
Expand Down
10 changes: 6 additions & 4 deletions tests/functional/test_new_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,9 @@ def test_new_resolver_requires_python_error(script: PipTestEnvironment) -> None:
)

message = (
"Package 'base' requires a different Python: "
"{}.{}.{} not in '<2'".format(*sys.version_info[:3])
"Package 'base' requires a different Python: " "{}.{}.{} not in '<2'".format(
*sys.version_info[:3]
)
)
assert message in result.stderr, str(result)

Expand Down Expand Up @@ -1169,8 +1170,9 @@ def test_new_resolver_no_deps_checks_requires_python(
)

message = (
"Package 'base' requires a different Python: "
"{}.{}.{} not in '<2'".format(*sys.version_info[:3])
"Package 'base' requires a different Python: " "{}.{}.{} not in '<2'".format(
*sys.version_info[:3]
)
)
assert message in result.stderr

Expand Down
3 changes: 1 addition & 2 deletions tests/lib/configuration_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Helpers for tests that check configuration
"""
"""Helpers for tests that check configuration"""

import contextlib
import functools
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/filesystem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Helpers for filesystem-dependent tests.
"""
"""Helpers for filesystem-dependent tests."""

import os
from contextlib import contextmanager
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/options_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Provides helper classes for testing option handling in pip
"""
"""Provides helper classes for testing option handling in pip"""

from optparse import Values
from typing import List, Tuple
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/requests_mocks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Helper classes as mocks for requests objects.
"""
"""Helper classes as mocks for requests objects."""

from io import BytesIO
from typing import Any, Callable, Dict, Iterator, List, Optional
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def make_environ(self) -> Dict[str, Any]:


def _mock_wsgi_adapter(
mock: Callable[["WSGIEnvironment", "StartResponse"], "WSGIApplication"]
mock: Callable[["WSGIEnvironment", "StartResponse"], "WSGIApplication"],
) -> "WSGIApplication":
"""Uses a mock to record function arguments and provide
the actual function that should respond.
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/test_wheel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Tests for wheel helper.
"""
"""Tests for wheel helper."""

import csv
from email import message_from_string
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/wheel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Helper for building wheels as would be in test cases.
"""
"""Helper for building wheels as would be in test cases."""

import csv
import itertools
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/resolution_resolvelib/test_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def resolver(preparer: RequirementPreparer, finder: PackageFinder) -> Resolver:


def _make_graph(
edges: List[Tuple[Optional[str], Optional[str]]]
edges: List[Tuple[Optional[str], Optional[str]]],
) -> "DirectedGraph[Optional[str]]":
"""Build graph from edge declarations."""

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_user_cache_dir_unicode(self, monkeypatch: pytest.MonkeyPatch) -> None:
return

def my_get_win_folder(csidl_name: str) -> str:
return "\u00DF\u00E4\u03B1\u20AC"
return "\u00df\u00e4\u03b1\u20ac"

monkeypatch.setattr(
platformdirs.windows, # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class FakeCommandWithUnicode(FakeCommand):
_name = "fake_unicode"

def run(self, options: Values, args: List[str]) -> int:
logging.getLogger("pip.tests").info(b"bytes here \xE9")
logging.getLogger("pip.tests").info(b"unicode here \xC3\xA9".decode("utf-8"))
logging.getLogger("pip.tests").info(b"bytes here \xe9")
logging.getLogger("pip.tests").info(b"unicode here \xc3\xa9".decode("utf-8"))
return SUCCESS


Expand Down
Loading

0 comments on commit b44f3b4

Please sign in to comment.