[configparser] Fix return type of RawConfigParser.read#15551
Open
LeonDeKunlun wants to merge 6 commits intopython:mainfrom
Open
[configparser] Fix return type of RawConfigParser.read#15551LeonDeKunlun wants to merge 6 commits intopython:mainfrom
RawConfigParser.read#15551LeonDeKunlun wants to merge 6 commits intopython:mainfrom
Conversation
srittau
requested changes
Mar 24, 2026
Collaborator
srittau
left a comment
There was a problem hiding this comment.
We should use overloads here instead of returning a hard-to-handle list[str | bytes] type indiscriminately.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: meson (https://github.com/mesonbuild/meson)
+ mesonbuild/cmdline.py:46:5: error: Signature of "read" incompatible with supertype "configparser.RawConfigParser" [override]
+ mesonbuild/cmdline.py:46:5: note: Superclass:
+ mesonbuild/cmdline.py:46:5: note: @overload
+ mesonbuild/cmdline.py:46:5: note: def [AnyStr: (str, bytes)] read(self, filenames: AnyStr | PathLike[AnyStr], encoding: str = ...) -> list[AnyStr]
+ mesonbuild/cmdline.py:46:5: note: @overload
+ mesonbuild/cmdline.py:46:5: note: def read(self, filenames: Iterable[str | PathLike[str]], encoding: str | None = ...) -> list[str]
+ mesonbuild/cmdline.py:46:5: note: @overload
+ mesonbuild/cmdline.py:46:5: note: def read(self, filenames: Iterable[bytes | PathLike[bytes]], encoding: str | None = ...) -> list[bytes]
+ mesonbuild/cmdline.py:46:5: note: @overload
+ mesonbuild/cmdline.py:46:5: note: def read(self, filenames: Iterable[str | bytes | PathLike[str] | PathLike[bytes]], encoding: str | None = ...) -> list[str | bytes]
+ mesonbuild/cmdline.py:46:5: note: Subclass:
+ mesonbuild/cmdline.py:46:5: note: def read(self, filenames: str | bytes | PathLike[str] | PathLike[bytes] | Iterable[str | bytes | PathLike[str] | PathLike[bytes]], encoding: str | None = ...) -> list[str]
+ mesonbuild/cmdline.py:47:29: error: Argument 1 to "read" of "RawConfigParser" has incompatible type "str | bytes | PathLike[str] | PathLike[bytes] | Iterable[str | bytes | PathLike[str] | PathLike[bytes]]"; expected "str | PathLike[str]" [arg-type]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.