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

distutils & setuptools: Complete sub_commands ClassVar typing #11951

Merged
merged 3 commits into from
May 18, 2024
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
5 changes: 3 additions & 2 deletions stdlib/distutils/cmd.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ from _typeshed import Incomplete, Unused
from abc import abstractmethod
from collections.abc import Callable, Iterable
from distutils.dist import Distribution
from typing import Any, Literal
from typing import Any, ClassVar, Literal

class Command:
distribution: Distribution
sub_commands: list[tuple[str, Callable[[Command], bool] | None]]
# Any to work around variance issues
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]
def __init__(self, dist: Distribution) -> None: ...
@abstractmethod
def initialize_options(self) -> None: ...
Expand Down
6 changes: 4 additions & 2 deletions stdlib/distutils/command/build.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any
from collections.abc import Callable
from typing import Any, ClassVar

from ..cmd import Command

Expand Down Expand Up @@ -28,4 +29,5 @@ class build(Command):
def has_c_libraries(self): ...
def has_ext_modules(self): ...
def has_scripts(self): ...
sub_commands: Any
# Any to work around variance issues
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]
6 changes: 4 additions & 2 deletions stdlib/distutils/command/install.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any
from collections.abc import Callable
from typing import Any, ClassVar

from ..cmd import Command

Expand Down Expand Up @@ -60,4 +61,5 @@ class install(Command):
def has_headers(self): ...
def has_scripts(self): ...
def has_data(self): ...
sub_commands: Any
# Any to work around variance issues
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]
6 changes: 4 additions & 2 deletions stdlib/distutils/command/register.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from typing import Any
from collections.abc import Callable
from typing import Any, ClassVar

from ..config import PyPIRCCommand

class register(PyPIRCCommand):
description: str
sub_commands: Any
# Any to work around variance issues
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]
list_classifiers: int
strict: int
def initialize_options(self) -> None: ...
Expand Down
6 changes: 4 additions & 2 deletions stdlib/distutils/command/sdist.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any
from collections.abc import Callable
from typing import Any, ClassVar

from ..cmd import Command

Expand All @@ -11,7 +12,8 @@ class sdist(Command):
boolean_options: Any
help_options: Any
negative_opt: Any
sub_commands: Any
# Any to work around variance issues
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]
READMES: Any
template: Any
manifest: Any
Expand Down
6 changes: 3 additions & 3 deletions stubs/setuptools/setuptools/_distutils/cmd.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from _typeshed import Incomplete, Unused
from abc import abstractmethod
from collections.abc import Callable, Iterable
from typing import ClassVar, Literal
from typing_extensions import Self
from typing import Any, ClassVar, Literal

from .dist import Distribution

class Command:
distribution: Distribution
sub_commands: ClassVar[list[tuple[str, Callable[[Self], bool] | None]]]
# Any to work around variance issues
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]
def __init__(self, dist: Distribution) -> None: ...
def ensure_finalized(self) -> None: ...
@abstractmethod
Expand Down
4 changes: 3 additions & 1 deletion stubs/setuptools/setuptools/command/install.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from collections.abc import Callable
from typing import Any

from .._distutils.command import install as orig

class install(orig.install):
user_options: Any
boolean_options: Any
new_commands: Any
# Any to work around variance issues
new_commands: list[tuple[str, Callable[[Any], bool]] | None]
old_and_unmanageable: Any
single_version_externally_managed: Any
def initialize_options(self) -> None: ...
Expand Down
5 changes: 2 additions & 3 deletions stubs/setuptools/setuptools/command/upload_docs.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections.abc import Callable
from typing import Any, ClassVar
from typing_extensions import Self

from .upload import upload

Expand All @@ -10,8 +9,8 @@ class upload_docs(upload):
user_options: ClassVar[list[tuple[str, str | None, str]]]
boolean_options: ClassVar[list[str]]
def has_sphinx(self): ...
# The callable parameter is self: Self, but using Self still trips up mypy
sub_commands: ClassVar[list[tuple[str, Callable[[Self], bool] | None]]] # type: ignore[assignment]
# Any to work around variance issues
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]
upload_dir: Any
target_dir: Any
def initialize_options(self) -> None: ...
Expand Down