Skip to content

Commit 0458554

Browse files
[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 5ea9010) Co-authored-by: sobolevn <[email protected]>
1 parent 13f5a9a commit 0458554

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

.github/workflows/mypy.yml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- "Lib/_colorize.py"
1212
- "Lib/_pyrepl/**"
1313
- "Lib/test/libregrtest/**"
14+
- "Lib/tomllib/**"
1415
- "Misc/mypy/**"
1516
- "Tools/build/generate_sbom.py"
1617
- "Tools/cases_generator/**"
@@ -44,6 +45,7 @@ jobs:
4445
target: [
4546
"Lib/_pyrepl",
4647
"Lib/test/libregrtest",
48+
"Lib/tomllib",
4749
"Tools/build",
4850
"Tools/cases_generator",
4951
"Tools/clinic",

Lib/tomllib/_parser.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def get_or_create_nest(
210210
cont = cont[-1]
211211
if not isinstance(cont, dict):
212212
raise KeyError("There is no nest behind this key")
213-
return cont
213+
return cont # type: ignore[no-any-return]
214214

215215
def append_nest_to_list(self, key: Key) -> None:
216216
cont = self.get_or_create_nest(key[:-1])
@@ -679,7 +679,7 @@ def make_safe_parse_float(parse_float: ParseFloat) -> ParseFloat:
679679
instead of returning illegal types.
680680
"""
681681
# The default `float` callable never returns illegal types. Optimize it.
682-
if parse_float is float: # type: ignore[comparison-overlap]
682+
if parse_float is float:
683683
return float
684684

685685
def safe_parse_float(float_str: str) -> Any:

Lib/tomllib/mypy.ini

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Config file for running mypy on tomllib.
2+
# Run mypy by invoking `mypy --config-file Lib/tomllib/mypy.ini`
3+
# on the command-line from the repo root
4+
5+
[mypy]
6+
files = Lib/tomllib
7+
mypy_path = $MYPY_CONFIG_FILE_DIR/../../Misc/mypy
8+
explicit_package_bases = True
9+
python_version = 3.12
10+
pretty = True
11+
12+
# Enable most stricter settings
13+
enable_error_code = ignore-without-code
14+
strict = True
15+
strict_bytes = True
16+
local_partial_types = True
17+
warn_unreachable = True
18+
# TODO(@sobolevn): remove this setting and refactor any found problems
19+
disallow_any_generics = False

Misc/mypy/tomllib

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Lib/tomllib

Misc/mypy/typed-stdlib.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
_colorize.py
44
_pyrepl
5+
tomllib

0 commit comments

Comments
 (0)