Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**"
Expand Down Expand Up @@ -44,6 +45,7 @@ jobs:
target: [
"Lib/_pyrepl",
"Lib/test/libregrtest",
"Lib/tomllib",
"Tools/build",
"Tools/cases_generator",
"Tools/clinic",
Expand Down
4 changes: 2 additions & 2 deletions Lib/tomllib/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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:
Expand Down
19 changes: 19 additions & 0 deletions Lib/tomllib/mypy.ini
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions Misc/mypy/tomllib
1 change: 1 addition & 0 deletions Misc/mypy/typed-stdlib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

_colorize.py
_pyrepl
tomllib
Loading