Commit Graph

26 Commits

Author SHA1 Message Date
Jelle Zijlstra
55be42f6d6 add __fspath__ support to os.path (#2053)
Fixes #1997, #2068.

This is tricky because we need to get the return values right (see #1960 for
prior attempts) and we often run into python/mypy#3644. I found that I
could express most signatures correctly using a series of overloads.

A few other changes in here:
- Added splitunc, which according to https://docs.python.org/3/library/os.path.html
  should exist in both Unix and Windows.
- Made the second argument to os.path.curdir Optional to match the implementation.
- Fixed os.path.split, whose previous Path-aware signature triggered python/mypy#3644.
2018-05-15 10:31:40 -04:00
rchen152
38dc8f5a6a Switch usages of mypy_extensions.NoReturn over to typing.NoReturn. (#1942)
* Change mypy_extensions.NoReturn to typing.NoReturn everywhere.
2018-03-05 12:42:29 -08:00
rchen152
76c733dc5b Fix the return type of os.popen() (#1820) 2018-01-10 05:57:29 -08:00
Guido van Rossum
76685480e0 Misc fixes found by running mypy against Dropbox internal codebase "C". (#1575) 2017-08-25 20:34:13 -07:00
Jelle Zijlstra
318cada66c os: merge the top and bottom of os/__init__.pyi (#1458)
* 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.
2017-07-04 19:30:55 -07:00
Jelle Zijlstra
a419b696d4 make os.path identical in Python 2 and 3 (#1459)
Part of #1427. I don't think we can actually merge these until we merge
os/__init__.pyi too, which will take a few more PRs.
2017-07-04 19:27:27 -07:00
Jelle Zijlstra
4a5ff0bb11 use PEP 526-style annotations in os stubs (#1428)
And fix some TODOs.

This will help me check these stubs with my stubcheck tool, and is better
for consistency anyway.
2017-06-22 05:49:23 -07:00
Matthias Kramm
6f07424246 fix types in os.path (#1363)
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. )
2017-05-31 10:43:26 -07:00
elmar bucher
579f25896b fix posix and win32 specific realpath path.pyi definition (PR 2) (#1345)
Fixes #1335.
2017-05-24 18:54:50 -07:00
David Euresti
26360e821b Merge stdlib/{2,3}/os/path.pyi (#1150)
* Merge stdlib/{2,3}/os/path.pyi

To be renamed into stdlib/2and3/os/path.pyi later.

Also fixes #50

* CR fixes
2017-04-09 19:27:25 -07:00
David Euresti
b03e79886e Fix os.getenv and friends to have consistent types (#1131) 2017-04-03 21:21:35 -07:00
Guido van Rossum
6a06dd40e1 Revert "Make os.stat_result and friends NamedTuples" (#1113)
* Revert "Added missing attributes of typing.Generator and typing.AsyncGenerator (#886)"

This reverts commit 8b26422b95.
2017-03-29 12:03:50 -07:00
David Euresti
6c3e175c8d Make os.stat_result and friends NamedTuples (#1103) 2017-03-29 10:36:04 -07:00
David Euresti
ec83ed90eb Fix some type errors in os module. (#1101)
* Fix some type errors in os module.

Found these because they were different between Python 2 and 3.

* Code Review changes

* Make it __arg0
2017-03-26 16:39:07 -07:00
David Euresti
2888b53924 Merge comments between stdlib/{2,3}/os/__init__.pyi to make diffing easier (#1099) 2017-03-25 20:50:21 -07:00
David Euresti
ce3a76bb97 Fix arg types for os.execv* (#1075) 2017-03-22 10:50:15 -07:00
David Euresti
b362177cc4 Fix typo 2017-03-20 22:36:44 -07:00
David Euresti
2804788efa Bring some things back to Union types 2017-03-20 22:29:43 -07:00
David Euresti
a4d70e5b01 Bring some things back to Union types 2017-03-20 22:26:06 -07:00
David Euresti
66fbb26aec Use Union[bytes, Text] in os.pyi
In order to unify these two versions I'm making all paths be _PathType = Union[bytes, Text]
Fixes #439
2017-03-20 21:56:14 -07:00
David Euresti
d57bce361f Reorder 2/os/__init__.py for combining
This was a simple reordering of the lines in the file so that it looks like 3/os/__init__.py.
This should let us more easily combine the files
2017-03-20 12:06:20 -07:00
David Fisher
2cb8e184cc Add NoReturn (#811)
* Add NoReturn
2017-01-04 13:38:05 -08:00
Lukasz Langa
c0c982ada5 Add missing Dict imports. 2016-12-21 01:15:26 -08:00
Lukasz Langa
147772950f Fixing flake8 E265 errors 2016-12-20 00:16:44 -08:00
Lukasz Langa
fe0e3744cc Fixing flake8 E261 errors 2016-12-19 22:09:35 -08:00
Guido van Rossum
cb97bb54c0 Move 2.7 to 2 (#635)
Closes #579.
2016-10-26 16:24:49 -07:00