Commit Graph

42 Commits

Author SHA1 Message Date
Shantanu ab36ecb784 io: add open_code for py38 (#3769) 2020-02-22 12:53:16 +01:00
Shantanu 35e45964fc io: mark positional-only args (#3721) 2020-02-05 16:23:31 +01:00
Shantanu d5851eca6f io: minor fixes for arguments (#3642) 2020-01-24 09:22:19 +01:00
cshesse 9a32f0d26a add raw property to BufferedIOBase (#3483) 2019-12-04 08:20:07 +01:00
cshesse 91f445ef11 fix incorrect param name in FileIO (#3484) 2019-11-24 00:08:53 +01:00
Sebastian Rittau 256b3ce8ab Remove a bunch of unused imports (#3323) 2019-10-08 07:59:32 -07:00
Ryan Morshead b9342eca0a add IncrementalNewlineDecoder constructor (#3311) 2019-10-06 17:22:03 +02:00
Ryan Morshead 3743b64b07 IncrementalNewlineDecoder.decode accepts str (#3312)
The decode method of IncrementalNewlineDecoder accepts a string when its decoder is None.
2019-10-06 11:33:26 +02:00
Rebecca Chen 90aa27b54a Fix the signature of IOBase._checkClosed(). (#3305)
* In Python 2, the optional `msg` argument was missing.
* In Python 3, the method was missing altogether.

Reference:
https://github.com/python/cpython/blob/2.7/Lib/_pyio.py#L423
https://github.com/python/cpython/blob/3.6/Lib/_pyio.py#L443
2019-10-04 14:53:48 -07:00
Rebecca Chen fab2ee0d7c Remove unnecessary quotes around forward references. (#3191) 2019-08-16 20:29:32 -07:00
Michael Lee b294782183 Make most contextmanager __exit__ signatures return Optional[bool] (#3179)
This pull request is a follow-up to https://github.com/python/mypy/issues/7214.

In short, within that mypy issue, we found it would be helpful to
determine between contextmanagers that can "swallow" exceptions vs ones
that can't. This helps prevent some false positive when using flags that
analyze control flow such as `--warn-unreachable`. To do this,
Jelle proposed assuming that only contextmanagers where the `__exit__`
returns `bool` are assumed to swallow exceptions.

This unfortunately required the following typeshed changes:

1. The typing.IO, threading.Lock, and concurrent.futures.Executor
   were all modified so `__exit__` returns `Optional[None]` instead
   of None -- along with all of their subclasses.

   I believe these three types are meant to be subclassed, so I felt
   picking the more general type was correct.

2. There were also a few concrete types (e.g. see socketserver,
   subprocess, ftplib...) that I modified to return `None` -- I checked
   the source code, and these all seem to return None (and don't appear
   to be meant to be subclassable).

3. contextlib.suppress was changed to return bool. I also double-checked
   the unittest modules and modified a subset of those contextmanagers,
   leaving ones like `_AssertRaisesContext` alone.
2019-08-16 16:13:33 -07:00
Sebastian Rittau 9ccf9356bf Remove Python 3.4 support (#3147)
Closes #3123
2019-07-27 10:58:21 +02:00
William Ayd 8e89faa90f Added Optional (#3125)
Fixes #3124
2019-07-17 10:08:46 +02:00
Michael Lee efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Siva Chandra 701f970c6f Add overrides for the methods 'readlines' and 'writelines' in TextIOBase. (#2551)
Without the overrides, MRO will pick the methods in IOBase which have
the wrong signatures.
2018-10-30 22:44:18 +01:00
Yusuke Miyazaki 6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -07:00
Sebastian Rittau b05e99297c Drop Python 3.3 support from several stubs (#2266)
* Drop Python 3.3 support from importlib stubs

* Drop Python 3.3 support from html and symbol stubs
2018-06-20 16:46:11 -07:00
Jelle Zijlstra 00cda79cf5 add io.TextIOWrapper.read in 3.3 (#2248)
This is needed to make TextIOWrapper and a few classes that inherit
from it concrete in 3.3. I am actually not sure whether this method
exists at runtime; there's nothing in
https://docs.python.org/3/library/io.html#io.TextIOWrapper
that suggests it was added in 3.4. In any case, it hardly matters
since 3.3 usage should be very rare now.
2018-06-17 23:47:07 +01:00
Jelle Zijlstra 6bbf3d89eb Further improve codecs stubs (#2217)
- remove header comments
- uppercase type aliases
- remove old-style type annotations
- unquote forward refs
- reformat the file
- remove values for globals
- don't use private names from codecs stub in io.pyi
2018-06-11 22:24:34 -07:00
Jelle Zijlstra 37aba00fe8 fix using ZipFile as a ContextManager (#2043) 2018-04-12 12:29:22 -07:00
Sebastian Rittau 6d7173b70b Add StringIO.name and BytesIO.name (#1802)
Also, change the type of StringIO.name (Python 3) from str to Any.

Neither StringIO nor BytesIO actually define a name field, but the
super-class IO[T] of both in typeshed does define a read-only property.
This means that sub-classes of StringIO and BytesIO adding this field
will not typecheck correctly.

Closes: #1790
2018-01-26 14:34:06 -08:00
rchen152 f6b60cb3ea A couple fixes to the io stubs. (#1811)
1. The 'name' argument to FileIO.init can be either a string or an integer: https://docs.python.org/2/library/io.html#io.FileIO
2. An mmap.mmap object can be used in most places that a bytearray can: https://docs.python.org/3.5/library/mmap.html
2018-01-04 16:14:38 -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
Jelle Zijlstra eaf8972e48 complete Python 3 gzip stub (#1723)
* complete python 3 gzip stub
* IOBase.closed is read-only
2017-11-09 05:56:55 -08:00
Evan Krall 9db63fee91 Make IOBase.__enter__ return the same type as self. Fixes #1540. (#1541) 2017-08-11 16:06:07 -07:00
Jelle Zijlstra 32d9c8cb8f make io.IncrementalNewlineDecoder concrete (#1489)
Part of #1476
2017-07-19 20:28:25 +03:00
Jelle Zijlstra ac651d2f8c Fix a few TODOs (#1487)
* fix some easy TODOs

* fix io
2017-07-19 20:27:50 +03: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
Yusuke Miyazaki c19e266dcf Fix StringIO stub for Python 3 (#1275) 2017-05-19 17:02:57 -07:00
David Euresti 1260d41cd1 Fix type of IO.writelines. (#949)
This lets you use generators to writelines
2017-02-21 14:25:00 -08:00
Lukasz Langa 147772950f Fixing flake8 E265 errors 2016-12-20 00:16:44 -08:00
Lukasz Langa 6b5c6626d6 Fixing flake8 E121, E122, E123, E124, E125, E126 errors 2016-12-19 23:53:19 -08:00
Lukasz Langa fe0e3744cc Fixing flake8 E261 errors 2016-12-19 22:09:35 -08:00
Eklavya Sharma 7f7a5789bd Add attribute 'name' to StringIO (#600)
Add an attribute 'name' of type str to StringIO.StringIO in python2
and io.StringIO in python2 and python3.

Fixes #598.
2016-10-12 07:34:58 -07:00
Guido van Rossum 39325bf159 Mypy now supports sys.platform and sys.version_info checks (#410) 2016-07-27 13:25:29 -07:00
Jukka Lehtosalo e05edb60f1 Mypy stub fixes for strict optional mode (#366) 2016-07-13 09:38:40 -07:00
Valérian Rousset e9efb31aa7 fix integration of io with mypy (#196) 2016-05-12 16:52:36 -07:00
Valérian Rousset 9fdac6e0df improve io (#194)
* added types to io, some version-specific variants
* remove _io (moved the classes to io)
* remove internal, unused xml.etree._ListDataStream
2016-05-11 10:47:24 -07:00
David Fisher 44d278045f Fix tests 2016-03-11 16:33:02 -08:00
Matthias Kramm 94c9ce8fd0 Consistently use '= ...' for optional parameters. 2015-11-09 13:55:02 -08:00
Matthias Kramm 4fe8915d44 Add missing '-> None' to all __init__ methods. 2015-11-09 10:25:11 -08:00
Matthias Kramm 337abed05a add (overwrite with) mypy stubs, if available 2015-09-30 09:59:44 -07:00