]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-133117: Run mypy on `tomllib` in CI (#133118)
authorsobolevn <mail@sobolevn.me>
Wed, 30 Apr 2025 08:45:58 +0000 (11:45 +0300)
committerGitHub <noreply@github.com>
Wed, 30 Apr 2025 08:45:58 +0000 (11:45 +0300)
.github/workflows/mypy.yml
Lib/tomllib/_parser.py
Lib/tomllib/mypy.ini [new file with mode: 0644]
Misc/mypy/tomllib [new symlink]
Misc/mypy/typed-stdlib.txt

index cb1b9fb5dbf82db18a6cd3663da0fbc9c5cf959b..908daaf3a6019a5aaae8cc984cf3d319b5ad5cfe 100644 (file)
@@ -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",
index 0e522c3a69e6fecc32cf5dd415340016cc426dcd..da56af3f34d9b224a98f00db0735869db684d237 100644 (file)
@@ -282,7 +282,7 @@ class NestedDict:
                 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])
@@ -741,7 +741,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 (file)
index 0000000..0297d19
--- /dev/null
@@ -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 (symlink)
index 0000000..20f34d4
--- /dev/null
@@ -0,0 +1 @@
+../../Lib/tomllib
\ No newline at end of file
index 8cd6858b4e591e52ff8729ff1e702c2ade7fbedd..9b27ee0d2de0771930af28b285d83b81a3058c20 100644 (file)
@@ -2,3 +2,4 @@
 
 _colorize.py
 _pyrepl
+tomllib
\ No newline at end of file