aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/setuptools/py3/setuptools/_distutils/dist.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2025-01-20 22:58:34 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-01-20 23:35:05 +0300
commit4c5957b4d22d3e94079c335ea6f2da8fc786de47 (patch)
tree00128ce0a17332e1e519368158742bf08ed5da22 /contrib/python/setuptools/py3/setuptools/_distutils/dist.py
parent6d1e12141d962a0b930005bd2019fe29aee28ace (diff)
downloadydb-4c5957b4d22d3e94079c335ea6f2da8fc786de47.tar.gz
Intermediate changes
commit_hash:723bd7a1ba6f9f6935191482507173119b20ba23
Diffstat (limited to 'contrib/python/setuptools/py3/setuptools/_distutils/dist.py')
-rw-r--r--contrib/python/setuptools/py3/setuptools/_distutils/dist.py39
1 files changed, 34 insertions, 5 deletions
diff --git a/contrib/python/setuptools/py3/setuptools/_distutils/dist.py b/contrib/python/setuptools/py3/setuptools/_distutils/dist.py
index 154301baff..33ed8ebd7a 100644
--- a/contrib/python/setuptools/py3/setuptools/_distutils/dist.py
+++ b/contrib/python/setuptools/py3/setuptools/_distutils/dist.py
@@ -4,6 +4,8 @@ Provides the Distribution class, which represents the module distribution
being built/installed/distributed.
"""
+from __future__ import annotations
+
import contextlib
import logging
import os
@@ -13,6 +15,7 @@ import sys
import warnings
from collections.abc import Iterable
from email import message_from_file
+from typing import TYPE_CHECKING, Literal, TypeVar, overload
from packaging.utils import canonicalize_name, canonicalize_version
@@ -27,6 +30,12 @@ from .errors import (
from .fancy_getopt import FancyGetopt, translate_longopt
from .util import check_environ, rfc822_escape, strtobool
+if TYPE_CHECKING:
+ # type-only import because of mutual dependence between these modules
+ from .cmd import Command
+
+_CommandT = TypeVar("_CommandT", bound="Command")
+
# Regex to define acceptable Distutils command names. This is not *quite*
# the same as a Python NAME -- I don't allow leading underscores. The fact
# that they're very similar is no coincidence; the default naming scheme is
@@ -139,7 +148,7 @@ Common commands: (see '--help-commands' for more)
self.dry_run = False
self.help = False
for attr in self.display_option_names:
- setattr(self, attr, 0)
+ setattr(self, attr, False)
# Store the distribution meta-data (name, version, author, and so
# forth) in a separate object -- we're getting to have enough
@@ -169,7 +178,7 @@ Common commands: (see '--help-commands' for more)
# and sys.argv[1:], but they can be overridden when the caller is
# not necessarily a setup script run from the command-line.
self.script_name = None
- self.script_args = None
+ self.script_args: list[str] | None = None
# 'command_options' is where we store command options between
# parsing them (from config files, the command-line, etc.) and when
@@ -269,6 +278,8 @@ Common commands: (see '--help-commands' for more)
self.want_user_cfg = True
if self.script_args is not None:
+ # Coerce any possible iterable from attrs into a list
+ self.script_args = list(self.script_args)
for arg in self.script_args:
if not arg.startswith('-'):
break
@@ -722,7 +733,7 @@ Common commands: (see '--help-commands' for more)
except AttributeError:
description = "(no description available)"
- print(" %-*s %s" % (max_length, cmd, description))
+ print(f" {cmd:<{max_length}} {description}")
def print_commands(self):
"""Print out a help message listing all available commands with a
@@ -829,7 +840,15 @@ Common commands: (see '--help-commands' for more)
raise DistutilsModuleError(f"invalid command '{command}'")
- def get_command_obj(self, command, create=True):
+ @overload
+ def get_command_obj(
+ self, command: str, create: Literal[True] = True
+ ) -> Command: ...
+ @overload
+ def get_command_obj(
+ self, command: str, create: Literal[False]
+ ) -> Command | None: ...
+ def get_command_obj(self, command: str, create: bool = True) -> Command | None:
"""Return the command object for 'command'. Normally this object
is cached on a previous call to 'get_command_obj()'; if no command
object for 'command' is in the cache, then we either create and
@@ -900,7 +919,17 @@ Common commands: (see '--help-commands' for more)
except ValueError as msg:
raise DistutilsOptionError(msg)
- def reinitialize_command(self, command, reinit_subcommands=False):
+ @overload
+ def reinitialize_command(
+ self, command: str, reinit_subcommands: bool = False
+ ) -> Command: ...
+ @overload
+ def reinitialize_command(
+ self, command: _CommandT, reinit_subcommands: bool = False
+ ) -> _CommandT: ...
+ def reinitialize_command(
+ self, command: str | Command, reinit_subcommands=False
+ ) -> Command:
"""Reinitializes a command to the state it was in when first
returned by 'get_command_obj()': ie., initialized but not yet
finalized. This provides the opportunity to sneak option