-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Update signature of ConfigParser.get() #501
Conversation
Issue #492 This signature seems to break the protocol of `MutableMappting[str, _section]`
Thanks for trying to tackle this one! I've thought about this more, and I think the right thing to do (for now) is to add The problem here is quite deep, you can read more about it at python/mypy#1237 and python/typing#241. But as a short-term solution, the Of course if you pass a ConfigParser object to a function that requires a Mapping and that function happens to call I think there are other problems with configparser.pyi too (e.g. read() takes a string too, and RawConfigParser is not there at all) but those can wait until another PR. |
I can't find the documentation about |
It should look like this:
|
You should still specify the correct signature (according to configparser docs, ignoring MutableMapping). |
# should be def get(self, section: str, option: str, *, raw: bool = ..., vars: _section = ..., fallback: str = ...) -> str: ... | ||
# but it is incompatible with MutableMapping | ||
def get(self, *args, **kwargs): # type: ignore | ||
# type: ignore since this is incompatible with MutableMapping |
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.
Please don't start this comment with exactly # type: ignore
since that may trigger other tools looking for # type: ignore
on a new line. Just prefix with "Uses" or something.
ConfigParser <: RawConfigParser, with __init__ changes: * delimiters and onward are kwargs only * no converters at the end
Thanks! Phew! |
Issue #492
This signature seems to break the protocol of
MutableMappting[str, _section]