Skip to content

configparser: allow default_section=None - #16262

Open
ekanshul wants to merge 2 commits into
python:mainfrom
ekanshul:configparser-default-section-none
Open

configparser: allow default_section=None#16262
ekanshul wants to merge 2 commits into
python:mainfrom
ekanshul:configparser-default-section-none

Conversation

@ekanshul

Copy link
Copy Markdown
Contributor

Closes #12700

Widen RawConfigParser.default_section and the default_section parameter of RawConfigParser.__init__ to str | None, since passing None works at runtime to disable the default section and is relied on in the wild (e.g. setuptools).

Agent used: Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

setuptools (https://github.com/pypa/setuptools)
+ setuptools/config/expand.py:371: error: Unused "type: ignore" comment  [unused-ignore]
+ setuptools/config/expand.py:372: error: Cannot assign to a method  [method-assign]
+ setuptools/config/expand.py:372: error: Incompatible types in assignment (expression has type "type[str]", variable has type "Callable[[str], str]")  [assignment]
+ setuptools/config/expand.py:375: error: Argument 1 to "pop" of "dict" has incompatible type "str | None"; expected "str"  [arg-type]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should None be an acceptable default_section parameter of configparser.ConfigParser

2 participants