Commit Graph

56 Commits

Author SHA1 Message Date
Sebastian Rittau
87d7dd3d95 Fix annotations with literal values (#3411) 2019-10-28 06:59:28 -07: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
0602840cc2 Make the type of timeout Optional[float] everywhere in subprocess. (#3241) 2019-09-18 11:05:49 +02: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
628eee29f7 Use Literal in a few more places (#3176) 2019-08-10 13:08:18 -07:00
Sebastian Rittau
9ccf9356bf Remove Python 3.4 support (#3147)
Closes #3123
2019-07-27 10:58:21 +02:00
Michael J. Sullivan
3ad3ed82c7 Overload the constructor of subprocess.Popen (#3113)
This takes advantage of a recent mypy change to respect the return
type of `__new__`. Using that it does the same tedious overloads
as `run` and `check_output`.
2019-07-16 15:41:33 -07:00
Michael J. Sullivan
b43e1d674f Use Literal overloads to give better types to subprocess (#3110)
This gives better types to `subprocess.check_output` and `subprocess.run`
by laboriously overloading using literals.

To support `run`, I turned `CompletedProcess` into `_CompletedProcess[T]`
with `CompletedProcess = _CompletedProcess[Any]`. I could pretty easily
be convinced that it would be better to just make `CompletedProcess`
generic, though.

I'd like to do the same for Popen but need to make mypy support
believing the type of `__new__` in order for that to work.
2019-07-10 14:44:27 -07:00
Michael Lee
efb67946f8 Use variable annotations everywhere (#2909) 2019-04-13 10:40:52 +02:00
Jakub Stasiak
9a92056105 Document the Python 3.7 variant of subprocess.check_output (#2592) 2018-11-19 09:41:05 +01:00
Jelle Zijlstra
1bc1fc2117 add constructor arguments for TimeoutExpired (#2466)
Previously, constructing a TimeoutExpired directly worked because Exception allowed arbitrary kwargs. We fixed that recently, but now mypy gives an error on creating a TimeoutExpired with legal arguments.
2018-09-18 14:02:38 +02:00
Ollie Ford
2e7e8cc009 Add 3.7 variant of subprocess.run (#2409)
Python 3.7 added:
  - `text` as an alias of `universal_newlines`
  - `capture_output` for `stdout=PIPE,stderr=PIPE`

cf. https://docs.python.org/3.7/library/subprocess.html
2018-08-23 11:50:23 -07:00
Yusuke Miyazaki
6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -07:00
Sebastian Rittau
95eff73ab2 Drop Python 3.3 support from several stubs (#2265)
* Drop Python 3.3 support from several stubs

* Revert wrong socketserver changes
2018-06-20 16:49:47 -07:00
Jelle Zijlstra
b1a0b8ad6e add subprocess.STARTUPINFO and some associated constants (#2041) 2018-04-12 12:29:42 -07:00
Nipunn Koorapati
5af337b438 Add subprocess annotation for TimeoutExpired (#1954) 2018-03-13 08:26:59 -07:00
Miguel Gaiowski
a8465da863 Add stub for subprocess.list2cmdline function (#1898) 2018-03-02 11:04:22 -08:00
Roy Williams
f4e3657c57 Allow subprocess functions to accept PathLike objects in 3.6 and above (#1713)
* Allow subprocess functions to accept PathLike objects in 3.6 and above

* Split up _PATH from _TXT in subprocess
2017-11-06 10:28:08 -08:00
Michael Lee
8afc1b7a08 Change subprocess constants to be type int (#1577)
This change modifies the PIPE, STDOUT, and DEVNULL constants in the
subprocess module to be of type 'int'.

Note that the Python 2 subprocess module was already typed this way;
this commit is just updating the Python 3 subprocess module in the same
way.
2017-08-26 17:07:25 -07:00
Antoine Reversat
6fe68fd120 [subprocess.run] Make timeout and input optional (#1426) 2017-06-21 13:28:16 -07:00
Cooper Lees
4656153478 Allow subprocess stdout + stderr be Optional (#1375)
- 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
2017-06-01 17:46:14 -07:00
Jason Fried
a2aa93ac29 subprocess.py env and cmd arguments accept None (#1291) 2017-05-22 15:06:24 -07:00
Sergey Passichenko
6207eb8cde Add args attribute to subprocess.Popen (#1267) 2017-05-14 13:41:38 -07:00
Jelle Zijlstra
1d6e3f492e Fix incorrect usage of AnyStr (#1215)
* Fix incorrect usage of AnyStr

- sqlite3 was using Union[bytes, AnyStr], which doesn't make sense
- The urllib functions I changed accept either bytes or str for their "safe"
  argument
- Also added supports for PathLike to pstats
- Remove some unused imports of AnyStr

* pstats: python 2 accepts unicode
2017-04-27 08:47:59 -07:00
Shengpei Zhang
c0bbfbdec5 add encoding parameter for subprocess.check_output() function in Python 3.6+ (#1095)
* add encoding parameter for check_output() function in Python 3.6+

* add errors parameter for subprocess.check_output() function
2017-03-25 14:07:25 -07:00
Guido van Rossum
fd77dd2e7a Make type of 'env' more flexible (#1091)
See https://github.com/python/typeshed/pull/1059#issuecomment-289150121
2017-03-24 15:58:01 -07:00
Josiah Boning
62f57e4cef Improve types for subprocess module (#1059)
* Improve types for CalledProcessError

This adds union types in the constructor to account for parameters that
might be either byte strings or unicode strings. At the same time, this
*removes* specific types from the user-accessible fields, to avoid the
need for users to at every use site specify which types their particular
instance was instantiated with.

* remove 'moral' comments; add List import; change 'str' to 'Text'

* import Text

* List -> Sequence; reinsert 'moral' comments

* Regularize string types everywhere

This defines _TXT and _CMD aliases, and uses them everywhere applicable.

Also brings the _FILE alias to python3.

* fix typo; possibly fix indentation

* remove trailing comma, which caused problems in python 2 tests

* fix py2 outputs to be bytes; tweak descriptive comments; remove one AnyStr
2017-03-24 08:23:36 -07:00
Antoine Reversat
01b3915b3f Add encoding and errors keyword arguments (new in 3.6) (#1001) 2017-03-14 10:44:10 -07:00
Łukasz Langa
05cba488a5 Revert "Fix click annotation syntax and add missing keyword arguments to subprocess (new in 3.76) (#999)"
This reverts commit 43a1f761b2.
2017-03-14 08:13:14 -07:00
Antoine Reversat
43a1f761b2 Fix click annotation syntax and add missing keyword arguments to subprocess (new in 3.76) (#999)
* Fix click annotations

* Add encoding and errors keyword arguments (new in 3.6)
2017-03-14 08:02:12 -07:00
Jelle Zijlstra
a9bb7f89d3 Fixes to subprocess.CompletedProcess (#895) 2017-01-29 20:16:49 -08:00
Lukasz Langa
fe0e3744cc Fixing flake8 E261 errors 2016-12-19 22:09:35 -08:00
Lukasz Langa
b84f20a011 Fixing flake8 W errors 2016-12-19 21:52:56 -08:00
Philip House
830c2fb089 updating stderr to return type Any (#776) 2016-12-16 11:51:52 +00:00
Philip House
bc252d69ac set subprocess stdout to be type Any (#581) (#761) 2016-12-13 14:23:45 +00:00
George King
dccc29bc2f Add None to type union for subprocess.Popen.communicate input. (#743)
* Add `None` to type union for `subprocess.Popen.communicate` stub's `input` parameter.

* subprocess.communicate `input` annotated as `Optional[AnyStr]` for both 2.7 and 3.x; `timeout` as `Optional[float]`.
2016-12-07 14:46:34 -08:00
Guido van Rossum
8d1026cade Fix timeout parameter to Popen.wait() -- it is optional (in both senses). 2016-10-15 21:12:32 -07:00
Sebastian Meßmer
b9ab4ae1c2 Add timeout parameter to subprocess.Popen.wait() (#607)
Also define TimeoutExpired exception.
2016-10-15 14:59:40 -07:00
Sebastian Meßmer
052574d821 Add missing type hints to subprocess.pyi (#539) 2016-09-13 09:17:17 -07:00
David Fisher
f209136b3c Make appropriate Popen constructor args Optional (#457) 2016-08-08 20:14:13 -07:00
Guido van Rossum
cc1f92103d Minor cleanup of subprocess.pyi 2016-08-05 17:32:17 -07:00
jdelic
1ac3c2f173 update subprocess module stub for Python 3.5 (#426) 2016-08-05 17:31:10 -07:00
wreed4
382cb5fe20 Updating subprocess.pyi to support python 3.5 (#438)
* Updating subprocess.pyi to support python 3.5 

Also added DEVNULL which was added in 3.3

* Incorrectly checked sys.version_info

* Addressed travis build failures

Forgot that __init__ should return None and also forgot "self" on a method. Like a dummy.
2016-08-05 07:01:34 -07:00
Daniël van Eeden
51a519b358 Add timeout argument to Popen communicate (#423)
This was added in Python 3.3
2016-08-03 15:39:35 -07:00
Eklavya Sharma
a7754c3eff subprocess: Fix return type of check_output.
check_output's return type can be str if universal_newlines=True.
2016-07-07 22:04:29 +05:30
Matthias Kramm
7bef3added Merge pull request #297 from alvarocaceres/subprocess
Fix signatures of call, check_call and check_output in subprocess
2016-07-06 10:54:01 -07:00
Eklavya Sharma
15714bb0e8 Set a default value for output in CalledProcessError.__init__ (#329) 2016-07-02 07:40:09 -07:00
Alvaro Caceres
5886a5dfcd Fix signatures of call, check_call and check_output in subprocess 2016-06-15 13:34:02 -05:00
Tim Abbott
ea734c69d0 Fix subprocess stubs (#198)
* subprocess.CalledProcessError output argument is optional.

* subprocess.CalledProcessError takes stderr argument in python3.

* subprocess: Fix type for command in call() and friends.

The stubs didn't correctly support the fact that you can pass a string
as well as a sequence of strings.
2016-05-12 14:45:23 -07:00