[+] improve typing

This commit is contained in:
Siarhei Siniak 2025-05-19 16:58:40 +03:00
parent 5e6b2b2e63
commit d30cdc7d70
2 changed files with 16 additions and 4 deletions

@ -11,7 +11,7 @@ import unittest.mock
import logging import logging
import typing import typing
from typing_extensions import (cast,) from typing_extensions import (cast, Protocol,)
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
import pip._internal.commands.show import pip._internal.commands.show
@ -24,6 +24,7 @@ if typing.TYPE_CHECKING:
import pip._internal.resolution.base import pip._internal.resolution.base
import pip._internal.resolution.resolvelib.resolver import pip._internal.resolution.resolvelib.resolver
import pip._internal.operations.prepare import pip._internal.operations.prepare
import pip._internal.index.package_finder
from typing import ( from typing import (
Literal, Optional, Iterable, Any, Literal, Optional, Iterable, Any,
@ -55,6 +56,15 @@ def pip_show(
class pip_resolve_t: class pip_resolve_t:
class build_package_finder_t(Protocol):
def __call__(
self,
options: Any,
session: Any,
target_python: Any,
ignore_requires_python: Any,
) -> 'pip._internal.index.package_finder.PackageFinder': ...
class kwargs_t: class kwargs_t:
class mode_t(enum.StrEnum): class mode_t(enum.StrEnum):
copy_paste = "copy_paste" copy_paste = "copy_paste"
@ -152,17 +162,18 @@ def pip_resolve(
session = t1.get_default_session(options) session = t1.get_default_session(options)
target_python = pip._internal.cli.cmdoptions.make_target_python(options) target_python = pip._internal.cli.cmdoptions.make_target_python(options)
finder = cast( finder = cast(
pip_resolve_t.build_package_finder_t,
getattr( getattr(
t1, t1,
'_build_package_finder' '_build_package_finder'
) )
) )(
t1._build_package_finder(
options=options, options=options,
session=session, session=session,
target_python=target_python, target_python=target_python,
ignore_requires_python=options.ignore_requires_python, ignore_requires_python=options.ignore_requires_python,
) )
build_tracker = t1.enter_context( build_tracker = t1.enter_context(
pip._internal.operations.build.build_tracker.get_build_tracker() pip._internal.operations.build.build_tracker.get_build_tracker()
) )

@ -205,7 +205,8 @@ reportUnnecessaryIsInstance = "warning"
reportUnusedClass = "error" reportUnusedClass = "error"
#reportUnusedImport = "error" #reportUnusedImport = "error"
reportUnusedImport = "none" reportUnusedImport = "none"
reportUnusedFunction = "error" # reportUnusedFunction = "error"
reportUnusedFunction = "warning"
#reportUnusedVariable = "error" #reportUnusedVariable = "error"
reportUnusedVariable = "warning" reportUnusedVariable = "warning"
reportUntypedBaseClass = "error" reportUntypedBaseClass = "error"