-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
configparser.SectionProxy.get* methods aren't correctly typed #1543
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
Comments
I think we can cover the majority of use cases by simply copying the definitions down from This won't help people who are subclassing |
Go for it. |
Cool, looking now. The test case for this issue (thanks to @reddraggone9 in #1527 (comment)): from configparser import ConfigParser
config = ConfigParser()
config.read_dict({'section': {'key': 'false'}})
assert config['section'].getboolean('key') is False
reveal_type(config['section'].getboolean('key'))
reveal_type(config['section'].getfloat('key'))
reveal_type(config['section'].getint('key')) That currently outputs:
but should output
|
These methods are partially applied (with the section that is being proxied in SectionProxy) at runtime, so will always be present. Fixes python#1543.
The commit above fixes this, but I committed it on top of #1527 so I'll wait for that to be merged to rebase and propose an MP. |
#1527 is merged. |
These methods are partially applied (with the section that is being proxied in SectionProxy) at runtime, so will always be present. Fixes python#1543.
These methods are partially applied (with the section that is being proxied in SectionProxy) at runtime, so will always be present. Fixes #1543.
On instantiation,
configparser.SectionProxy
takes as an argument the parser that it's a section of and usessetattr
to populate itself with partially applied converters (i.e. methods that start withget
) that the parser it is passed has.Currently, this is stubbed as:
which means that
ConfigParser()['section'].getboolean('key')
type checks asAny
, whereas it should in fact bebool
.The text was updated successfully, but these errors were encountered: