Commit Graph

103 Commits

Author SHA1 Message Date
Debjyoti Biswas
f4a646d43c Add PathLike to genericpath.exists and re-export (#3897)
Closes#3492
2020-04-02 09:51:59 +02:00
Shantanu
2d3635f10d os: fix platform availability (#3832) 2020-03-07 12:59:55 +01:00
Shantanu
a19caac361 os.path: fix arg names (#3748) 2020-02-21 11:55:21 +01:00
Shantanu
7924d36656 os: fix various arg names (#3726) 2020-02-05 20:57:51 +01:00
Shantanu
10d33f5364 os: fix getenvb, scandir (#3723)
* os: fix getenvb
* os: scandir accepts None
2020-02-05 20:55:45 +01:00
Shantanu
fb286e1eb2 os.register_at_fork: fix signature (#3720) 2020-02-05 16:22:24 +01:00
Shantanu
12cbdcf337 os: mark positional-only args (#3719)
Also remove unnecessary branch for os.urandom
2020-02-05 16:21:03 +01:00
Erick
394ee4a9ae added f_fsid: int to os.statvfs_result for >= 3.7 (#3608) 2020-01-13 20:08:59 +01:00
Rebecca Chen
3b3fc6a57f Make os.statvfs_result inherit from typing.NamedTuple. (#3603) 2020-01-10 22:42:29 +01:00
Vury Leo
e7430508b0 Fix argument name of os.link/symlink (#3590) 2020-01-08 13:16:02 +01:00
Daniel Hahler
2f65683d7b Fix type for os.terminal_size to Tuple (#3450) 2019-11-10 19:30:12 +01:00
Benjamin Peterson
2023394b37 exec, spawn: Allow bytes for environment keys and values. (#3419)
A more correct type would be Mapping[Union[bytes, str], Union[bytes, str]], but our hands are tied by the invariance of mapping keys.
2019-10-29 11:48:36 -07:00
Sebastian Rittau
ec7960a8cb Convert namedtuples to class syntax (#3321) 2019-10-20 10:37:33 +02:00
Sebastian Rittau
0501e2b329 Annotations for remaining Python 3.8 additions (#3358)
* Add os.add_dll_directory()
* Add memfd_create() and flags
* Add type annotation to flags
* Add stat_result.st_reparse_tag and flags
* Add ncurses_version
* Add Path.link_to()
* Add Picker.reducer_override()
* Add plistlib.UID
* Add has_dualstack_ipv6() and create_server()
* Add shlex.join()
* Add SSL methods and fields
* Add Python 3.8 statistics functions and classes
* Remove obsolete sys.subversion
* Add sys.unraisablehook
* Add threading.excepthook
* Add get_native_id() and Thread.native_id
* Add Python 3.8 tkinter methods
* Add CLOCK_UPTIME_RAW
* Add SupportsIndex
* Add typing.get_origin() and get_args()
* Add unicodedata.is_normalized
* Add unittest.mock.AsyncMock

Currently this is just an alias for Any like Mock and MagicMock. All of
these classes should probably be sub-classing Any and add their own
methods. See also #3224.

* Add unittest cleanup methods
* Add IsolatedAsyncioTestCase
* Add ElementTree.canonicalize() and C14NWriterTarget
* cProfile.Profile can be used as a context manager
* Add asyncio task name handling
* mmap.flush() now always returns None
* Add posonlyargcount to CodeType
2019-10-14 09:53:48 +02:00
Sebastian Rittau
256b3ce8ab Remove a bunch of unused imports (#3323) 2019-10-08 07:59:32 -07:00
Sebastian Rittau
c32e1e2280 Enable --disallow-any-generics for stubs (#3288) 2019-10-01 05:31:34 -07:00
Rebecca Chen
3f8c2169d1 Define listdir in posix and import it in os. (#3258) 2019-09-23 23:41:05 +02:00
Sebastian Rittau
9ccf9356bf Remove Python 3.4 support (#3147)
Closes #3123
2019-07-27 10:58:21 +02:00
Michael J. Sullivan
f06f2e97bb Make os.altsep Optional on non-win32 platforms (#2918)
Keep it str on win32 to avoid breaking win32-specific code that relies
on it.
2019-04-12 23:00:19 -07:00
Rebecca Chen
d275e73e1f Remove pytype workaround in os/__init__.pyi. (#2797)
Pytype release 2019.02.13 fixed the bug that
necessitated this workaround.
2019-02-14 12:29:19 -08:00
Utkarsh Gupta
1a37368cc0 __init__.pyi: Add __getitem__() to stat_result() (#2753)
Fixes #2751
2019-02-09 16:07:10 +01:00
Michael J. Sullivan
95afb86022 Move posix.stat_result to os.stat_result on python 3 (#2683)
In python 3, posix.stat_result is a re-export of os.stat_result, while
in python 2 it was the reverse. Update typeshed to reflect this.
2018-12-13 19:20:42 +01:00
Sebastian Rittau
517d2b6012 Remove unneeded ignores (#2624) 2018-11-23 09:51:44 -08:00
Sebastian Rittau
006a79220f Flake8 fixes (#2549)
* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
2018-10-24 07:20:53 -07:00
Michael J. Sullivan
da6e18caf7 Make os.dup2 return int on Python 3.7 (#2543)
* Add inheritable param also
2018-10-23 23:15:35 +02:00
Adam Simpkins
79b2df4b24 os.DirEntry.stat() accepts a follow_symlinks keyword argument (#2538)
This function accepts the same arguments as the is_file() and is_dir()
methods in this class.

This also marks the follow_symlinks arguments to `is_dir()` and
`is_file()` as keyword only.
2018-10-23 23:13:33 +02:00
Sebastian Rittau
ea2122741f os.path.exists (Py 3) accepts a file descriptor (#2451)
Closes #1653
2018-09-24 07:53:44 -07:00
Jelle Zijlstra
574807d9ea os.get_terminal_size also exists on Windows (#2338)
... at least according to https://docs.python.org/3/library/os.html#os.get_terminal_size.

Related to python/mypy#5370.
2018-07-18 10:25:12 -07:00
Linda_pp
8d13a377d4 Allow to specify None to encoding parameter of fdopen (fix #2321) (#2324) 2018-07-11 19:43:13 -07:00
Yusuke Miyazaki
1ae2ba0fbe Use sys.platform instead of comments (#2286) 2018-07-03 08:13:04 -07:00
Jelle Zijlstra
94ab32ba59 Fix abstract classes for Python 3 (#2239)
* add metaclass=ABCMeta to some classes

* mark some more classes as explicitly abstract

* make some more classes concrete
2018-06-16 10:18:54 -07:00
Anthony Sottile
56c93c85c0 Add NoReturn to execv* family of functions (#2226) 2018-06-15 07:55:45 -07:00
Michael J. Sullivan
db1316d26b os.path.relpath can use a default argument and still use str (#2159) 2018-05-24 13:23:17 -07:00
Jelle Zijlstra
b89f9553e9 keep os.path in 2 and 3 consistent (#2152)
We can't merge these because os/__init__ is still different.

Also slight refactor of tests/check_consistent.py to avoid `from os import path`.
2018-05-22 07:14:13 -07:00
Michael Lee
709b193416 Rearrange overloads to account for optional arguments (#2150)
Basically, the same thing as [my previous pull request][0], except the
fixes are now focusing on functions with overlapping argument counts.

  [0]: https://github.com/python/typeshed/pull/2138
2018-05-19 09:20:16 -07:00
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
Jelle Zijlstra
482f207b3c os.fwalk supports bytes (#2013)
python/cpython@8f6b344 and https://bugs.python.org/issue28682.

I could not use the _PathLike alias because that includes bytes.

Part of #1965.
2018-04-06 11:22:15 -07:00
Jelle Zijlstra
54ecefef04 removals in Python 3.7 (#2018)
Last part of #1965.
2018-04-06 11:11:29 -07:00
Jelle Zijlstra
ce0656a8c7 add some more Python 3.7 features (#2014) 2018-04-06 11:08:30 -07: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
Roy Williams
71c2a94cb8 Allow os.listdir to accept a PathLike in Python3.6 (#1894) 2018-02-16 16:42:58 -08:00
Jelle Zijlstra
2dd85c3658 move os.stat_result into posix stub (#1818)
This removes the circular dependency between the os and posix stub, which
is somehow triggering python/mypy#4442. We should ideally fix the mypy bug,
but since it's easy enough to fix the import cycle, we might as well do that
too.
2018-01-09 13:50:56 -08:00
Jelle Zijlstra
4ee508a032 make os.scandir work as a context manager (#1787)
Rework of #1583. Fixes #1573.

See documentation in https://docs.python.org/3/library/os.html#os.scandir.
2018-01-02 10:17:38 -08:00
hashstat
6accffca28 popen() is function, not method, so remove self argument (#1671) 2017-10-12 12:16:14 -07:00
hashstat
d333474ed9 Update and add stubs for os module (#1645) 2017-10-09 21:02:10 -07:00
Øystein Olsen
6bfd43d6b6 Update utime stub (#1594)
times can be either a tuple of ints or floats
2017-09-23 08:57:38 -04:00
Zack Hsi
a4285af4c2 Support PathLike argument to os.path.split (#1588) 2017-09-05 20:04:55 -07:00
Jelle Zijlstra
c40b7afc14 accept PathLike in os.scandir (#1546) 2017-08-21 13:54:22 -07:00
Adam Dangoor
7fe417ca58 In Python 3.4 and above, os.makedirs and os.removedirs use the kwarg "name" rather than "path" (#1536) 2017-08-08 18:42:29 -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