https://github.com/python/cpython/commit/04585544826751a59e7e7815f824e4a2a6675546
commit: 04585544826751a59e7e7815f824e4a2a6675546
branch: 3.13
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: sobolevn <m...@sobolevn.me>
date: 2025-04-30T12:57:57Z
summary:

[3.13] gh-133117: Run mypy on `tomllib` in CI (GH-133118) (#133192)

gh-133117: Run mypy on `tomllib` in CI (GH-133118)
(cherry picked from commit 5ea9010e8910cb97555c3aef4ed95cca93a74aab)

Co-authored-by: sobolevn <m...@sobolevn.me>

files:
A Lib/tomllib/mypy.ini
A Misc/mypy/tomllib
M .github/workflows/mypy.yml
M Lib/tomllib/_parser.py
M Misc/mypy/typed-stdlib.txt

diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml
index cb1b9fb5dbf82d..908daaf3a6019a 100644
--- a/.github/workflows/mypy.yml
+++ b/.github/workflows/mypy.yml
@@ -11,6 +11,7 @@ on:
       - "Lib/_colorize.py"
       - "Lib/_pyrepl/**"
       - "Lib/test/libregrtest/**"
+      - "Lib/tomllib/**"
       - "Misc/mypy/**"
       - "Tools/build/generate_sbom.py"
       - "Tools/cases_generator/**"
@@ -44,6 +45,7 @@ jobs:
         target: [
           "Lib/_pyrepl",
           "Lib/test/libregrtest",
+          "Lib/tomllib",
           "Tools/build",
           "Tools/cases_generator",
           "Tools/clinic",
diff --git a/Lib/tomllib/_parser.py b/Lib/tomllib/_parser.py
index 45ca7a89630f0e..86322e2761befc 100644
--- a/Lib/tomllib/_parser.py
+++ b/Lib/tomllib/_parser.py
@@ -210,7 +210,7 @@ def get_or_create_nest(
                 cont = cont[-1]
             if not isinstance(cont, dict):
                 raise KeyError("There is no nest behind this key")
-        return cont
+        return cont  # type: ignore[no-any-return]
 
     def append_nest_to_list(self, key: Key) -> None:
         cont = self.get_or_create_nest(key[:-1])
@@ -679,7 +679,7 @@ def make_safe_parse_float(parse_float: ParseFloat) -> 
ParseFloat:
     instead of returning illegal types.
     """
     # The default `float` callable never returns illegal types. Optimize it.
-    if parse_float is float:  # type: ignore[comparison-overlap]
+    if parse_float is float:
         return float
 
     def safe_parse_float(float_str: str) -> Any:
diff --git a/Lib/tomllib/mypy.ini b/Lib/tomllib/mypy.ini
new file mode 100644
index 00000000000000..0297d19e2c8445
--- /dev/null
+++ b/Lib/tomllib/mypy.ini
@@ -0,0 +1,19 @@
+# Config file for running mypy on tomllib.
+# Run mypy by invoking `mypy --config-file Lib/tomllib/mypy.ini`
+# on the command-line from the repo root
+
+[mypy]
+files = Lib/tomllib
+mypy_path = $MYPY_CONFIG_FILE_DIR/../../Misc/mypy
+explicit_package_bases = True
+python_version = 3.12
+pretty = True
+
+# Enable most stricter settings
+enable_error_code = ignore-without-code
+strict = True
+strict_bytes = True
+local_partial_types = True
+warn_unreachable = True
+# TODO(@sobolevn): remove this setting and refactor any found problems
+disallow_any_generics = False 
\ No newline at end of file
diff --git a/Misc/mypy/tomllib b/Misc/mypy/tomllib
new file mode 120000
index 00000000000000..20f34d49da0cd4
--- /dev/null
+++ b/Misc/mypy/tomllib
@@ -0,0 +1 @@
+../../Lib/tomllib
\ No newline at end of file
diff --git a/Misc/mypy/typed-stdlib.txt b/Misc/mypy/typed-stdlib.txt
index 8cd6858b4e591e..9b27ee0d2de077 100644
--- a/Misc/mypy/typed-stdlib.txt
+++ b/Misc/mypy/typed-stdlib.txt
@@ -2,3 +2,4 @@
 
 _colorize.py
 _pyrepl
+tomllib
\ No newline at end of file

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to