-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add missing None
return to RawConfigParser.get
#8380
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
Conversation
Fix #7476 This adds support to RawConfigParser.get to return None as seen on these lines in cPython: https://github.com/python/cpython/blob/main/Lib/configparser.py#L773-L774
None
return to RawConfigParser.get
None
return to RawConfigParser.get
Update `SectionProxy.get` with the missing `| None` from `RawConfigParser`.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Presumably
A couple ways to fix this:
You will also have to adjust |
This comment has been minimized.
This comment has been minimized.
I've added the overloads for Regarding making section proxy generic, I can do that but it seems to really ripple throughout as we have to adjust the |
Indeed, the inheritance is a bit unfortunate: |
…nd `RawConfigParser` differences
This comment has been minimized.
This comment has been minimized.
stdlib/configparser.pyi
Outdated
@overload | ||
def get(self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ..., fallback: _T) -> str | _T: ... | ||
def get( | ||
self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ..., fallback: _T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at zproject/config.py in zulip (from last mypy_primer output), mypy seems to think that _T
is str
, and complains when you do fallback=None
. I will try to fix that.
self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ..., fallback: _T | |
self, section: str, option: str, *, raw: bool = ..., vars: _Section | None = ..., fallback: _T | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted this. Returning a possibly None
value is good if you pass fallback=None
.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This still seems a bit too disruptive to me: all mypy_primer results above (you need to click "1 similar comment") are usages of We have a couple options to choose from:
|
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Thanks! |
Fix #7476
This adds support to RawConfigParser.get to return None as seen on these lines in cPython:
https://github.com/python/cpython/blob/main/Lib/configparser.py#L773-L774