posixpath.pyi did a '*' import of genericpath.pyi and then redefined
everything it imported. Removes the duplicate definitions from posixpath
and improves the ones in genericpath.
* os: merge the top and bottom of os/__init__.pyi
Part of #1427. In preparation for merging the two stubs, I'm making the files
identical as much as possible. This PR merges the top of the file, down to
but not including the definition of statvfs_result, and the bottom up to
and including os.utime.
This PR mostly adds more "if sys.version_info" block. Until the merger
completes, we'll have some Python 2 blocks in the Python 3 stub and vice versa.
I also add a few missing constants and arguments.
In followup PRs I'll merge the rest of the file. I'll put the trickiest part
(the return values of functions like os.stat) in its own PR.
* back out DirEntry from py2
It relies on stat_result which we don't have yet in py2.
* urlparse: allow unicode arguments in more places
Part of #1411
urlunsplit() and similar functions accept either unicode or str in all
places. Their actual return type is unicode if any of the arguments is
unicode and nonempty, which the type system can't exactly express. I
left the return type as str because str is implicitly promoted to
unicode, so using the return type in a place that accepts unicode should
work.
unquote, parse_qs, and parse_qsl return unicode if you pass them unicode,
so AnyStr is appropriate in their stubs.
* fix type for urldefrag
The return type was wrong; this function returns a 2-tuple. The second member of the tuple is always a `str` if the argument type does not contain '#', and otherwise matches the type of the argument.
* make io.pyi import _io.py(i), like io.py does
* make write/writelines take 'Any', on _IOBase
* Add missing constructors, fix inconsistencies.
* Also, as far as possible, try to simplify, by moving methods into base
classes.
* fix lint+mypy warnings
* add missing __enter__ methods
* make _IOBase inherit from BinaryIO
* make _TextIOBase not subclass _IOBase
* Add flags to pass on --warn-unused-ignores and --no-implicit-optional to mypy
* Make implicit Optional explicit in arg types (2and3 part)
* Convert {stdlib,third_party}/2 to explicit Optional
* DictReader should not be abstract. Reformat long lines.
* Make restval optional for DictWriter.__init__.
* The arg to reader() is *Iterable*, not *Iterator*.
* Improve signature of float() (use Union instead of overload).
Add an additional overload for the `repeat = n` case. Since we don't know
the numeric value of `repeat`, this just produces an iterator over an
arbitrary-length tuple.
* Update default values to `...` in `__init__` and `__new__` in `int` and `str`.
* Add `__new__` to `enum.IntEnum` to override inherited `__new__`.
* Add `type: ignore` comment to `IntEnum`
- Adding optional to _FILE for stderr + stdout arguments to subprocess functions
- Sometimes you might want subprocess commands to be quiet and other time print the output
Update stub for spwd
- Use `NamedTuple`
- Fix stub for Python 3
- Some attributes are changed from Python 2
- `sp_nam` -> `sp_namp`
- `sp_pwd` -> `sp_pwdp`
In Python 2, doing
os.path.join(u"foo", "bar")
is actually legal, and returns a unicode string.
Also os.path.relpath always returns the type of its first argument.
(The solution is not perfect -- e.g.
os.path.join("a", "b", "c", "d", u"e")
will still result in a type error. )
* Update stubs for `collections` module in both Pythons.
* Update `typing.NamedTuple` stub to have `_source` attribute.
* Fix compatibility of `deque.index` signature with supertype `Sequence`