From f9299d4e80e4ee328313eb041204df317c742631 Mon Sep 17 00:00:00 2001
From: Avasam <samuel.06@hotmail.com>
Date: Mon, 19 Feb 2024 18:11:13 -0500
Subject: [PATCH 1/4] Improve typing of `sysconfig.get_config_var(s)`

---
 stdlib/distutils/sysconfig.pyi                       | 11 ++++++++++-
 stdlib/sysconfig.pyi                                 |  7 ++++++-
 stubs/setuptools/setuptools/_distutils/sysconfig.pyi | 12 ++++++++++--
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi
index 464cfb639c6d..8d80692e1d64 100644
--- a/stdlib/distutils/sysconfig.pyi
+++ b/stdlib/distutils/sysconfig.pyi
@@ -1,6 +1,8 @@
 import sys
 from collections.abc import Mapping
 from distutils.ccompiler import CCompiler
+from typing import Literal, overload
+from typing_extensions import deprecated
 
 PREFIX: str
 EXEC_PREFIX: str
@@ -10,8 +12,15 @@ project_base: str
 python_build: bool
 
 def expand_makefile_vars(s: str, vars: Mapping[str, str]) -> str: ...
+@overload
+@deprecated("SO is deprecated, use EXT_SUFFIX")
+def get_config_var(name: Literal["SO"]) -> int | str | None: ...
+@overload
 def get_config_var(name: str) -> int | str | None: ...
-def get_config_vars(*args: str) -> Mapping[str, int | str]: ...
+@overload
+def get_config_vars() -> dict[str, str | int]: ...
+@overload
+def get_config_vars(*args: str) -> list[str | int]: ...
 def get_config_h_filename() -> str: ...
 def get_makefile_filename() -> str: ...
 def get_python_inc(plat_specific: bool = ..., prefix: str | None = None) -> str: ...
diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi
index 2edb71d78cdd..544b849842aa 100644
--- a/stdlib/sysconfig.pyi
+++ b/stdlib/sysconfig.pyi
@@ -1,5 +1,6 @@
 import sys
 from typing import IO, Any, Literal, overload
+from typing_extensions import deprecated
 
 __all__ = [
     "get_config_h_filename",
@@ -15,11 +16,15 @@ __all__ = [
     "parse_config_h",
 ]
 
+@overload
+@deprecated("SO is deprecated, use EXT_SUFFIX")
+def get_config_var(name: Literal["SO"]) -> Any: ...
+@overload
 def get_config_var(name: str) -> Any: ...
 @overload
 def get_config_vars() -> dict[str, Any]: ...
 @overload
-def get_config_vars(arg: str, *args: str) -> list[Any]: ...
+def get_config_vars(*args: str) -> list[Any]: ...
 def get_scheme_names() -> tuple[str, ...]: ...
 
 if sys.version_info >= (3, 10):
diff --git a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
index c82da4323054..08c227852e83 100644
--- a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
+++ b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
@@ -1,12 +1,20 @@
-from collections.abc import Mapping
+from typing import Literal, overload
+from typing_extensions import deprecated
 
 from setuptools._distutils.ccompiler import CCompiler
 
 PREFIX: str
 EXEC_PREFIX: str
 
+@overload
+@deprecated("SO is deprecated, use EXT_SUFFIX")
+def get_config_var(name: Literal["SO"]) -> int | str | None: ...
+@overload
 def get_config_var(name: str) -> int | str | None: ...
-def get_config_vars(*args: str) -> Mapping[str, int | str]: ...
+@overload
+def get_config_vars() -> dict[str, str | int]: ...  # type:ignore[overload-overlap]
+@overload
+def get_config_vars(*args: str) -> list[str | int]: ...
 def get_config_h_filename() -> str: ...
 def get_makefile_filename() -> str: ...
 def get_python_inc(plat_specific: bool = ..., prefix: str | None = ...) -> str: ...

From ab2e2efc3e08e9b85a3fef31b68bb4beebb0600f Mon Sep 17 00:00:00 2001
From: Avasam <samuel.06@hotmail.com>
Date: Mon, 19 Feb 2024 18:20:47 -0500
Subject: [PATCH 2/4] mypy says overloads overlap, but also gives the right
 return type

---
 stdlib/distutils/sysconfig.pyi                       | 2 +-
 stdlib/sysconfig.pyi                                 | 2 +-
 stubs/setuptools/setuptools/_distutils/sysconfig.pyi | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi
index 8d80692e1d64..3df12b6a6352 100644
--- a/stdlib/distutils/sysconfig.pyi
+++ b/stdlib/distutils/sysconfig.pyi
@@ -18,7 +18,7 @@ def get_config_var(name: Literal["SO"]) -> int | str | None: ...
 @overload
 def get_config_var(name: str) -> int | str | None: ...
 @overload
-def get_config_vars() -> dict[str, str | int]: ...
+def get_config_vars() -> dict[str, str | int]: ...  # type: ignore[overload-overlap]
 @overload
 def get_config_vars(*args: str) -> list[str | int]: ...
 def get_config_h_filename() -> str: ...
diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi
index 544b849842aa..e33a58b6fd17 100644
--- a/stdlib/sysconfig.pyi
+++ b/stdlib/sysconfig.pyi
@@ -22,7 +22,7 @@ def get_config_var(name: Literal["SO"]) -> Any: ...
 @overload
 def get_config_var(name: str) -> Any: ...
 @overload
-def get_config_vars() -> dict[str, Any]: ...
+def get_config_vars() -> dict[str, Any]: ...  # type: ignore[overload-overlap]
 @overload
 def get_config_vars(*args: str) -> list[Any]: ...
 def get_scheme_names() -> tuple[str, ...]: ...
diff --git a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
index 08c227852e83..019f5360068f 100644
--- a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
+++ b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
@@ -12,7 +12,7 @@ def get_config_var(name: Literal["SO"]) -> int | str | None: ...
 @overload
 def get_config_var(name: str) -> int | str | None: ...
 @overload
-def get_config_vars() -> dict[str, str | int]: ...  # type:ignore[overload-overlap]
+def get_config_vars() -> dict[str, str | int]: ...  # type: ignore[overload-overlap]
 @overload
 def get_config_vars(*args: str) -> list[str | int]: ...
 def get_config_h_filename() -> str: ...

From 791f63014df6a15ca7172a05d6af3c1e554fe5f0 Mon Sep 17 00:00:00 2001
From: Avasam <samuel.06@hotmail.com>
Date: Mon, 19 Feb 2024 18:28:16 -0500
Subject: [PATCH 3/4] Avoid overload-overlap

---
 stdlib/distutils/sysconfig.pyi                       | 4 ++--
 stdlib/sysconfig.pyi                                 | 4 ++--
 stubs/setuptools/setuptools/_distutils/sysconfig.pyi | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi
index 3df12b6a6352..a51d4a18970a 100644
--- a/stdlib/distutils/sysconfig.pyi
+++ b/stdlib/distutils/sysconfig.pyi
@@ -18,9 +18,9 @@ def get_config_var(name: Literal["SO"]) -> int | str | None: ...
 @overload
 def get_config_var(name: str) -> int | str | None: ...
 @overload
-def get_config_vars() -> dict[str, str | int]: ...  # type: ignore[overload-overlap]
+def get_config_vars() -> dict[str, str | int]: ...
 @overload
-def get_config_vars(*args: str) -> list[str | int]: ...
+def get_config_vars(arg: str, /, *args: str) -> list[str | int]: ...
 def get_config_h_filename() -> str: ...
 def get_makefile_filename() -> str: ...
 def get_python_inc(plat_specific: bool = ..., prefix: str | None = None) -> str: ...
diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi
index e33a58b6fd17..8c3296304379 100644
--- a/stdlib/sysconfig.pyi
+++ b/stdlib/sysconfig.pyi
@@ -22,9 +22,9 @@ def get_config_var(name: Literal["SO"]) -> Any: ...
 @overload
 def get_config_var(name: str) -> Any: ...
 @overload
-def get_config_vars() -> dict[str, Any]: ...  # type: ignore[overload-overlap]
+def get_config_vars() -> dict[str, Any]: ...
 @overload
-def get_config_vars(*args: str) -> list[Any]: ...
+def get_config_vars(arg: str, /, *args: str) -> list[Any]: ...
 def get_scheme_names() -> tuple[str, ...]: ...
 
 if sys.version_info >= (3, 10):
diff --git a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
index 019f5360068f..7eacaee71978 100644
--- a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
+++ b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
@@ -12,9 +12,9 @@ def get_config_var(name: Literal["SO"]) -> int | str | None: ...
 @overload
 def get_config_var(name: str) -> int | str | None: ...
 @overload
-def get_config_vars() -> dict[str, str | int]: ...  # type: ignore[overload-overlap]
+def get_config_vars() -> dict[str, str | int]: ...
 @overload
-def get_config_vars(*args: str) -> list[str | int]: ...
+def get_config_vars(arg: str, /, *args: str) -> list[str | int]: ...
 def get_config_h_filename() -> str: ...
 def get_makefile_filename() -> str: ...
 def get_python_inc(plat_specific: bool = ..., prefix: str | None = ...) -> str: ...

From a6dd5fdf64e4537dc9a469d45ea4e422b6c5c535 Mon Sep 17 00:00:00 2001
From: Avasam <samuel.06@hotmail.com>
Date: Mon, 19 Feb 2024 19:47:43 -0500
Subject: [PATCH 4/4] Add removal date

---
 stdlib/distutils/sysconfig.pyi                       | 2 +-
 stdlib/sysconfig.pyi                                 | 2 +-
 stubs/setuptools/setuptools/_distutils/sysconfig.pyi | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi
index a51d4a18970a..e2399a6cf36b 100644
--- a/stdlib/distutils/sysconfig.pyi
+++ b/stdlib/distutils/sysconfig.pyi
@@ -13,7 +13,7 @@ python_build: bool
 
 def expand_makefile_vars(s: str, vars: Mapping[str, str]) -> str: ...
 @overload
-@deprecated("SO is deprecated, use EXT_SUFFIX")
+@deprecated("SO is deprecated, use EXT_SUFFIX. Support is removed in Python 3.11")
 def get_config_var(name: Literal["SO"]) -> int | str | None: ...
 @overload
 def get_config_var(name: str) -> int | str | None: ...
diff --git a/stdlib/sysconfig.pyi b/stdlib/sysconfig.pyi
index 8c3296304379..807a979050e8 100644
--- a/stdlib/sysconfig.pyi
+++ b/stdlib/sysconfig.pyi
@@ -17,7 +17,7 @@ __all__ = [
 ]
 
 @overload
-@deprecated("SO is deprecated, use EXT_SUFFIX")
+@deprecated("SO is deprecated, use EXT_SUFFIX. Support is removed in Python 3.11")
 def get_config_var(name: Literal["SO"]) -> Any: ...
 @overload
 def get_config_var(name: str) -> Any: ...
diff --git a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
index 7eacaee71978..edcc64426d7b 100644
--- a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
+++ b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi
@@ -7,7 +7,7 @@ PREFIX: str
 EXEC_PREFIX: str
 
 @overload
-@deprecated("SO is deprecated, use EXT_SUFFIX")
+@deprecated("SO is deprecated, use EXT_SUFFIX. Support will be removed when this module is synchronized with stdlib Python 3.11")
 def get_config_var(name: Literal["SO"]) -> int | str | None: ...
 @overload
 def get_config_var(name: str) -> int | str | None: ...
