Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix a bug where inline configurations of error codes would lose their values if accompanied by another inline configuration. #19075

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

Open
wants to merge 17 commits into
base: master
Choose a base branch
Loading
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
solve the typing problem
  • Loading branch information
wyattscarpenter committed May 12, 2025
commit 000f25fd8cf83ae62afb3a19fe4c40fe817dae9c
20 changes: 8 additions & 12 deletions 20 mypy/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import tomli as tomllib

from collections.abc import Mapping, MutableMapping, Sequence
from typing import Any, Callable, Final, TextIO, Union
from typing import Any, Callable, Final, TextIO, TypedDict, Union
from typing_extensions import TypeAlias as _TypeAlias

from mypy import defaults
Expand Down Expand Up @@ -640,7 +640,7 @@ def parse_mypy_comments(
generated.
"""
errors: list[tuple[int, str]] = []
sections = {}
sections: dict[str, object] = {"enable_error_code": [], "disable_error_code": []}

for lineno, line in args:
# In order to easily match the behavior for bools, we abuse configparser.
Expand Down Expand Up @@ -681,16 +681,12 @@ def set_strict_flags() -> None:
# (the new_sections for an inline config *always* includes 'disable_error_code' and
# 'enable_error_code' fields, usually empty, which overwrite the old ones),
# we have to manipulate them specially.
if "enable_error_code" in new_sections:
assert isinstance(new_sections["enable_error_code"], list)
if "disable_error_code" in new_sections:
assert isinstance(new_sections["disable_error_code"], list)
new_sections["enable_error_code"] = list(
set(new_sections["enable_error_code"] + sections.get("enable_error_code", []))
)
new_sections["disable_error_code"] = list(
set(new_sections["disable_error_code"] + sections.get("disable_error_code", []))
)
assert isinstance(neec:=new_sections.get("enable_error_code", []), list)
assert isinstance(eec:=sections.get("enable_error_code", []), list)
assert isinstance(ndec:=new_sections.get("disable_error_code", []), list)
assert isinstance(dec:=new_sections.get("disable_error_code", []), list)
new_sections["enable_error_code"] = list(set(neec + eec))
new_sections["disable_error_code"] = list(set(ndec + dec))
sections.update(new_sections)
return sections, errors

Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.