Skip to content

Commit

Permalink
Merge pull request #12974 from notatallshaw/vendored-and-test-import-…
Browse files Browse the repository at this point in the history
…groups

Add vendored and test import groups to import sorting
  • Loading branch information
sbidoul authored Oct 13, 2024
2 parents 6c3943b + 43cc291 commit b0ebea9
Show file tree
Hide file tree
Showing 67 changed files with 95 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/12974.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Create two new import groups, "vendored" and "import", this only affects tests.
16 changes: 13 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,19 @@ select = [
]

[tool.ruff.lint.isort]
# Explicitly make tests "first party" as it's not in the "src" directory
known-first-party = ["tests"]
known-third-party = ["pip._vendor"]
section-order = [
"future",
"standard-library",
"third-party",
"vendored",
"first-party",
"tests",
"local-folder",
]

[tool.ruff.lint.isort.sections]
"vendored" = ["pip._vendor"]
"tests" = ["tests"]

[tool.ruff.lint.mccabe]
max-complexity = 33 # default is 10
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from pip import __file__ as pip_location
from pip._internal.locations import _USE_SYSCONFIG
from pip._internal.utils.temp_dir import global_tempdir_manager

from tests.lib import (
DATA_DIR,
SRC_DIR,
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

from pip._internal.build_env import BuildEnvironment, _get_system_sitepackages

from tests.lib import (
PipTestEnvironment,
TestPipResult,
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pytest

from pip._internal.commands import commands_dict

from tests.lib import PipTestEnvironment


Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from zipfile import ZipFile

from pip._internal.utils.urls import path_to_url

from tests.lib import PipTestEnvironment, create_basic_sdist_for_package

PYPROJECT_TOML = """\
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from pip._internal.cli.status_codes import ERROR
from pip._internal.configuration import CONFIG_BASENAME, get_configuration_files

from tests.lib import PipTestEnvironment
from tests.lib.configuration_helpers import ConfigurationMixin, kinds
from tests.lib.venv import VirtualEnvironment
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/test_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
from typing import List

import pytest

from pip._vendor.packaging.version import Version

from pip._internal.commands.debug import create_vendor_txt_map
from pip._internal.utils import compatibility_tags

from tests.lib import PipTestEnvironment


Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from pip._internal.cli.status_codes import ERROR
from pip._internal.utils.urls import path_to_url

from tests.lib import (
PipTestEnvironment,
ScriptFactory,
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/test_fast_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
from typing import Iterable

import pytest

from pip._vendor.packaging.utils import canonicalize_name

from pip._internal.utils.misc import hash_file

from tests.lib import PipTestEnvironment, TestData, TestPipResult


Expand Down
2 changes: 2 additions & 0 deletions tests/functional/test_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
from pathlib import Path

import pytest

from pip._vendor.packaging.utils import canonicalize_name

from pip._internal.models.direct_url import DirectUrl, DirInfo

from tests.lib import (
PipTestEnvironment,
TestData,
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.commands import commands_dict, create_command
from pip._internal.exceptions import CommandError

from tests.lib import InMemoryPip, PipTestEnvironment


Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.commands import create_command

from tests.lib import PipTestEnvironment


Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pip._internal.models.index import PyPI, TestPyPI
from pip._internal.utils.misc import rmtree
from pip._internal.utils.urls import path_to_url

from tests.lib import (
CertFactory,
PipTestEnvironment,
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_install_direct_url.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest

from pip._internal.models.direct_url import VcsInfo

from tests.lib import PipTestEnvironment, TestData, _create_test_package
from tests.lib.direct_url import get_created_direct_url

Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_invalid_versions_and_specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from pip._internal.metadata import select_backend

from tests.lib import PipTestEnvironment, TestData


Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from pip._internal.models.direct_url import DirectUrl, DirInfo

from tests.lib import (
PipTestEnvironment,
ScriptFactory,
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_new_resolver_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

from pip._internal.cli.status_codes import ERROR, SUCCESS

from tests.lib import PipTestEnvironment
from tests.lib.wheel import make_wheel

Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from pip._internal.build_env import BuildEnvironment
from pip._internal.req import InstallRequirement

from tests.lib import (
PipTestEnvironment,
TestData,
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_pip_runner_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path

from pip import __version__

from tests.lib import PipTestEnvironment


Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pip._internal.cli.status_codes import NO_MATCHES_FOUND, SUCCESS
from pip._internal.commands import create_command
from pip._internal.commands.search import highest_version, print_results, transform_hits

from tests.lib import PipTestEnvironment

if TYPE_CHECKING:
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pip import __version__
from pip._internal.commands.show import search_packages_info
from pip._internal.utils.unpacking import untar_file

from tests.lib import (
PipTestEnvironment,
TestData,
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from pip._internal.req.constructors import install_req_from_line
from pip._internal.utils.misc import rmtree

from tests.lib import (
PipTestEnvironment,
TestData,
Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_vcs_bazaar.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from pip._internal.vcs.bazaar import Bazaar
from pip._internal.vcs.versioncontrol import RemoteNotFoundError

from tests.lib import PipTestEnvironment, is_bzr_installed, need_bzr


Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_vcs_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pip._internal.utils.misc import HiddenText
from pip._internal.vcs import vcs
from pip._internal.vcs.git import Git, RemoteNotFoundError

from tests.lib import PipTestEnvironment, _create_test_package, _git_commit


Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_vcs_mercurial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from pip._internal.vcs.mercurial import Mercurial

from tests.lib import PipTestEnvironment, _create_test_package, need_mercurial


Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_vcs_subversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from pip._internal.vcs.subversion import Subversion
from pip._internal.vcs.versioncontrol import RemoteNotFoundError

from tests.lib import PipTestEnvironment, _create_svn_repo, need_svn


Expand Down
1 change: 1 addition & 0 deletions tests/functional/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pytest

from pip._internal.cli.status_codes import ERROR

from tests.lib import (
PipTestEnvironment,
TestData,
Expand Down
4 changes: 3 additions & 1 deletion tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
from zipfile import ZipFile

import pytest
from pip._vendor.packaging.utils import canonicalize_name
from scripttest import FoundDir, FoundFile, ProcResult, TestFileEnvironment

from pip._vendor.packaging.utils import canonicalize_name

from pip._internal.cli.main import main as pip_entry_point
from pip._internal.index.collector import LinkCollector
from pip._internal.index.package_finder import PackageFinder
Expand All @@ -44,6 +45,7 @@
from pip._internal.models.target_python import TargetPython
from pip._internal.network.session import PipSession
from pip._internal.utils.egg_link import _egg_link_names

from tests.lib.venv import VirtualEnvironment
from tests.lib.wheel import make_wheel

Expand Down
1 change: 1 addition & 0 deletions tests/lib/direct_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Optional

from pip._internal.models.direct_url import DIRECT_URL_METADATA_NAME, DirectUrl

from tests.lib import TestPipResult


Expand Down
2 changes: 2 additions & 0 deletions tests/unit/metadata/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from unittest import mock

import pytest

from pip._vendor.packaging.utils import NormalizedName

from pip._internal.metadata import (
Expand All @@ -15,6 +16,7 @@
)
from pip._internal.metadata.base import FilesystemWheel
from pip._internal.models.direct_url import DIRECT_URL_METADATA_NAME, ArchiveInfo

from tests.lib.wheel import make_wheel


Expand Down
1 change: 1 addition & 0 deletions tests/unit/metadata/test_metadata_pkg_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from unittest import mock

import pytest

from pip._vendor.packaging.requirements import Requirement
from pip._vendor.packaging.specifiers import SpecifierSet
from pip._vendor.packaging.utils import canonicalize_name
Expand Down
1 change: 1 addition & 0 deletions tests/unit/resolution_resolvelib/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pip._internal.resolution.resolvelib.factory import Factory
from pip._internal.resolution.resolvelib.provider import PipProvider
from pip._internal.utils.temp_dir import TempDirectory, global_tempdir_manager

from tests.lib import TestData


Expand Down
2 changes: 2 additions & 0 deletions tests/unit/resolution_resolvelib/test_requirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
from typing import List, Tuple

import pytest

from pip._vendor.resolvelib import BaseReporter, Resolver

from pip._internal.resolution.resolvelib.base import Candidate, Constraint, Requirement
from pip._internal.resolution.resolvelib.factory import Factory
from pip._internal.resolution.resolvelib.provider import PipProvider

from tests.lib import TestData

# NOTE: All tests are prefixed `test_rlr` (for "test resolvelib resolver").
Expand Down
1 change: 1 addition & 0 deletions tests/unit/resolution_resolvelib/test_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest import mock

import pytest

from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.resolvelib.resolvers import Result
from pip._vendor.resolvelib.structs import DirectedGraph
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from unittest import mock

import pytest

from pip._vendor import platformdirs

from pip._internal.utils import appdirs
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from unittest import mock

import pytest

from pip._vendor import requests
from pip._vendor.packaging.requirements import Requirement

Expand All @@ -35,6 +36,7 @@
_ensure_quoted_url,
)
from pip._internal.network.session import PipSession

from tests.lib import (
TestData,
make_test_link_collector,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from pip._internal.configuration import get_configuration_files, kinds
from pip._internal.exceptions import ConfigurationError

from tests.lib.configuration_helpers import ConfigurationMixin


Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Optional, Tuple

import pytest

from pip._vendor import rich

from pip._internal.exceptions import DiagnosticPipError, ExternallyManagedEnvironment
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest.mock import Mock, patch

import pytest

from pip._vendor.packaging.specifiers import SpecifierSet
from pip._vendor.packaging.tags import Tag
from pip._vendor.packaging.version import parse as parse_version
Expand All @@ -18,6 +19,7 @@
)
from pip._internal.models.target_python import TargetPython
from pip._internal.req.constructors import install_req_from_line

from tests.lib import TestData, make_test_finder


Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import FrozenSet, List, Optional, Set, Tuple

import pytest

from pip._vendor.packaging.specifiers import SpecifierSet
from pip._vendor.packaging.tags import Tag

Expand All @@ -25,6 +26,7 @@
from pip._internal.network.session import PipSession
from pip._internal.utils.compatibility_tags import get_supported
from pip._internal.utils.hashes import Hashes

from tests.lib import CURRENT_PY_VERSION_INFO
from tests.lib.index import make_mock_candidate

Expand Down
Loading

0 comments on commit b0ebea9

Please sign in to comment.