Commit Graph

19 Commits

Author SHA1 Message Date
Sebastian Rittau
44bdf6c6c7 Fix RawConfigParser.readfp() annotation (#2443)
Closes #689
2018-09-11 08:22:36 -07:00
Yusuke Miyazaki
581705d9ee Prefer to use ellipsis over pass (#2292) 2018-06-28 10:29:45 -07:00
Jelle Zijlstra
7abcd0f71f add ConfigParser.readfp in Python 3 (#2123)
https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.readfp

Fixes #2112
2018-06-11 14:10:52 -07:00
Pradyun Gedam
b6bd58268b Update base class to match the source file (#1899) 2018-02-18 09:03:09 -08:00
Jelle Zijlstra
324f1761f4 Change more defaults to ... (#1727) 2017-11-09 10:32:17 -08:00
Jelle Zijlstra
54dd6ba27c Change numerous default values to ... (#1722)
This is the convention, and some default values (e.g. strings) apparently
break pytype.
2017-11-09 06:28:40 -08:00
Daniel Watkins
1050b383a3 RawConfigParser dict_type argument should be a Type (#1572)
Fixes #1571.
2017-08-22 14:59:59 -07:00
Daniel Watkins
e8ece8ccce Replicate RawConfigParser.get* methods in SectionProxy (#1568)
These methods are partially applied (with the section that is being
proxied in SectionProxy) at runtime, so will always be present.

Fixes #1543.
2017-08-21 15:00:16 -07:00
Daniel Watkins
24a7bfb4bf Make configparser.RawConfigParser use SectionProxy where appropriate (#1527)
* Make configparser.RawConfigParser.__getitem__ return a SectionProxy

This reflects the code in the cpython tree and makes the following
(valid) code type-check correctly:

```
from configparser import ConfigParser

config = ConfigParser()
config.read_dict({'section': {'key': 'false'}})
assert config['section'].getboolean('key') is False
```

* RawConfigParser.items() returns SectionProxys not mappings

Because .items() uses __getitem__ to produce second item in each tuple.

* section argument to RawConfigParser.items is Optional

* Add comment explaining the status of RawConfigParser.items

TL;DR, we're hitting https://github.com/python/mypy/issues/3805 when
implemented correctly as an override, and
https://github.com/python/mypy/issues/1855 when we try to work around
that with a union.

* Correctly implement RawConfigParser.items overloading

* RawConfigParser.items(str) returns a List not an Iterable
2017-08-21 14:46:50 -07:00
Daniel Watkins
6f848e8ed8 Add definition for RawConfigParser._get_conv (#1542)
This allows subclasses that define get* methods to wrap _get_conv whilst
still typechecking correctly.
2017-08-21 14:09:42 -07:00
Jelle Zijlstra
5c328f12e1 configparser: support PathLike (#1547)
RawConfigParser.read has code explicitly supporting PathLike objects.

Also removed an unused import and widened the accepted type from
Sequence to Iterable.
2017-08-21 13:42:35 -07:00
Guido van Rossum
350563223f Add Optional[] for all remaining cases of x: <type> = None (#1424)
* Final round of adding Optional[] to type of arguments with default = None
* Update Travis to use --no-implicit-optionals and clarify CONTRIBUTING.md
2017-06-21 10:50:21 -07:00
Jelle Zijlstra
0bda8c0cef fixes and additions to the configparser stub (#1311)
* fixes and additions to the configparser stub

This broke pytype because of the type ignore. I think it's OK to blacklist
because another instance of this same error (stdlib/3/email/policy.pyi line 95)
is already blacklisted. We can remove it when the pytype parser is fixed to
allow type ignores in this context.

* add SectionProxy.__getattr__

* the __getattr__ returns Any

* don't need type ignore for pytype if we put it all on one line
2017-05-23 15:36:42 -07:00
Guido van Rossum
b369a3f2db Fix return type of RawConfigParser.items() 2017-01-11 07:09:27 -08:00
Madeleine Thompson
d7edb0365f RawConfigParser.items (#820)
The corresponding line is already present in the Python 2 ConfigParser stubs.
2017-01-10 15:56:26 -08:00
Lukasz Langa
6e2709906b Fixing flake8 B errors 2016-12-20 01:17:38 -08:00
Elazar
59585bbf54 Update signature of ConfigParser.get() (#501)
Fix #492

Also add RawConfigParser
2016-08-29 12:44:30 -07:00
Mickaël S
4f1eb9a63c Fix argument type for configparser.write (#284) 2016-06-10 19:49:37 +01:00
Martin Geisler
808016a510 Add stubs for configparser 2016-03-15 09:52:24 +01:00