Commit Graph

131 Commits

Author SHA1 Message Date
Jelle Zijlstra 7448f23d9f spwd: move to 2and3 and add missing argument 2017-03-20 08:39:24 -07:00
Eddie Antonio Santos 16babfdfda Stub for tty (#1038)
Adds Python 2 and 3 stubs for `tty` module.  Addresses one of the missing stubs mentioned in #1019.
2017-03-19 17:35:31 -07:00
Jelle Zijlstra 658abe7c9e Merge and complete stubs for sysconfig (#1040)
* unify and complete sysconfig stubs

* add missing imports

* and another
2017-03-19 17:34:08 -07:00
Jelle Zijlstra ee22a489d9 quopri: unify 2 and 3, add types 2017-03-19 13:08:54 -07:00
Jelle Zijlstra 7906059adb pyclbr: move to 2and3 (#1034)
* pyclbr: move to 2and3

This module is completely identical between 2 and 3 in CPython (apart from a small few syntax changes).

* fix typo
2017-03-19 13:05:07 -07:00
David Wetterau f35500caa8 Add stub for "binhex" module for 2and3 (#1028)
* added binhex for 2 and 3

* fix flake8 and use IO
2017-03-18 16:28:22 -07:00
Jelle Zijlstra cb7949b14e fixes to dis stubs (#1025)
- Add sys.version_info checks (mypy now supports them)
- Went over Python 3 docs and corrected a few things
- Reexport things that are imported from opcode
2017-03-18 14:50:31 -07:00
Jelle Zijlstra 52dcfeed12 merge 2 and 3 stubs for unicodedata (#1013)
* merge 2 and 3 stubs for unicodedata
* fix a few return types to str in py2
2017-03-17 10:39:44 -07:00
Jelle Zijlstra 349ff59f33 change empty bodies from "pass" to "..."
CONTRIBUTING.md says to prefer ... Not the most impactful change but fixing
these will allow us to lint for it in the future and get a consistent style.
2017-03-16 09:13:08 -07:00
Jelle Zijlstra 11350ed8cc Fix missing argument types in py3 stdlib (#995)
Still missing a few in _subprocess (a Windows-only private module) and decimal
(I gave up).
2017-03-14 11:43:42 -07:00
David Euresti 514bf736da Add stub for ftplib to 2and3 (#956) 2017-03-14 08:22:05 -07:00
Jelle Zijlstra eb07fd3c1a make sure typevars defined in stubs are private (#989)
And also a few type aliases I noticed in the process.

Found using https://github.com/JelleZijlstra/stublint/commit/59f9cac0951f431fbc3abf8803adeaac6e489aac
2017-03-13 07:32:40 -07:00
Jelle Zijlstra 984307bf45 fix odd version comparisons (#988)
"> (3,)" works but looks like the code is checking for Python 4.

"<= (3, 5)" was intended to check for versions up to and including 3.5, and probably works that
way in current type checkers. However, sys.version_info is actually a 5-tuple that is greater
than (3, 5), so a hypothetical type checker that uses the full version info would interpret
this check incorrectly.

This ensures that all version_info comparisons use <, >=, ==, or !=.
2017-03-12 20:48:48 -07:00
Jelle Zijlstra b6eec58d2c remove checks against patch versions (#987)
Both mypy and pytype only use the major and minor version in type checking. Using
checks like "sys.version_info >= (3, 4, 4)" won't actually work properly for
people type checking their code using version 3.4, because (3, 4) >= (3, 4, 4) will
always be false (at least in mypy's approach; not sure if pytype is different).
2017-03-12 20:16:09 -07:00
Jelle Zijlstra cf6c563ce1 codecs: merge 2 and 3 stubs (#960) 2017-03-10 15:50:14 -08:00
David Euresti a1e74b9261 Add stub for filecmp to 2and3 (#955)
* Add stub for filecmp to 2and3

* Fix spacing

* Moar spacing

* Use _SupportsBool

* Code review
2017-03-07 16:36:25 -08:00
David Euresti 63590301f7 Add stubs for py_compile. (#954)
* Add stubs for py_compile.

* Correct Text
2017-03-07 16:35:45 -08:00
Sebastian Meßmer afde2fd234 Fix type stubs for logging (#972)
Add missing type for two parameters
2017-03-06 08:05:42 -08:00
lincolnq 59789b8a3e Improve types for xml.etree.ElementTree (#930)
* Improve types for xml.etree.ElementTree

Update signatures to reflect the following peculiarities of the
ElementTree library:

- The elementtree library accepts unicode or bytes for most xml values
  in python2, and coerces everywhere -- but in python3, only str makes
  sense.
- In python 2, the library produces str or unicode instances
  unpredictably, depending on whether the xml is decodeable as ascii or
  not. In python 3, it always produces str instances.
- The parser functions accept unicode or bytes in 2 and 3 -- again, will
  coerce individual instances so heterogeneous lists are ok.
- In python 3, the tostring functions produce bytes or str, depending on
  the value of the 'encoding' parameter.

* improve docs
* Improve ElementFactory type by specifying dict of 2nd arg
2017-02-22 20:43:09 -08:00
David Euresti e3fb935ca4 Move opcode to 2and3 (#938)
* Move opcode to 2and3

* Fix python3 versions

* Fix tests

* Bring Dict back
2017-02-21 14:27:34 -08:00
Matthias Kramm 40754e312f fix import error in logging/__init__.pyi 2017-01-31 14:54:18 -08:00
Eklavya Sharma bc092ded69 pstats: Add default value for kwarg (#905)
According to python library docs, pstats.Stats.__init__ has a
keyword argument `stream' whose default value is `sys.stdout`.
2017-01-31 11:42:14 +00:00
Valérian Rousset fe15d91041 merge */xml/etree into 2and3/xml/etree (#899)
Fixes #287.
2017-01-30 13:19:28 -08:00
Matt Kimball bb5ba13315 Moved syslog from 2/ to 2and3/. Allow both forms of syslog.syslog. (#884) 2017-01-29 20:19:13 -08:00
Lucas Wiman 225f302135 Address str/unicode issue with logging.getLogger. (#883)
Fixes #843.
2017-01-29 11:40:20 -08:00
Jukka Lehtosalo 97bd6e37b9 Update argparse to accept unicode in many contexts
Change `str` to `Union[str, unicode]` where it seems safe.
I didn't change it in non-covariant contexts since that can
break user code.

I manually verified a subset of the changes by calling the
relevant function with unicode literals (ascii-only).

I'm using `Union[str, unicode]` instead of just `unicode`
so that the stub still works with tools that don't promote
`str` objects to `unicode`.
2017-01-18 08:43:49 -08:00
Guido van Rossum 94641f5a84 Revert "Make all single-constraint TypeVars to use bounds" (#806)
Reverts python/typeshed#804.

Reason: until python/mypy#1551 is fixed this gives an error whenever @skip() is used.

Specifically see https://github.com/python/typeshed/pull/804#issuecomment-269926655.
2017-01-01 16:35:50 -08:00
Michael Lee b46366e77d Make all single-constraint TypeVars to use bounds
According to the documentation in the typing module, TypeVars cannot
have only a single constraint. Attempting to do so will actually result
in an exception at runtime. (However, this error is currently ignored
by mypy -- see https://github.com/python/mypy/pull/2626 for a related
pending pull request).

This commit changes all instances of TypeVars using a single constraint
(e.g. `T = TypeVar('T', Foo)`) to use bounds instead (e.g.
`T = TypeVar('T', bound=Foo)`.

This seems to be the correct fix for plistlib after reading the module
docs, but it's less obvious this is correct for unittest. The unittest
module originally had `_FT = TypeVar('_FT', Callable[[Any], Any])` -- an
alternative fix would have been to do `_FT = Callable[[Any], Any]`.

Although I'm not entirely sure what it means to have a bound be a
Callable, I decided to make the assumption that the original authors
probably meant to use TypeVars instead of type aliases for a reason
(possibly to handle classes implementing `__call__`?)
2017-01-01 11:34:19 -08:00
Alex 6a15963e7d Add math.tau to typeshed (#801)
As per https://www.python.org/dev/peps/pep-0628/
2016-12-29 10:17:40 -08:00
Lukasz Langa c0c982ada5 Add missing Dict imports. 2016-12-21 01:15:26 -08:00
Lukasz Langa 5f416fae64 Add missing List imports. 2016-12-21 01:06:52 -08:00
Thomas Aynaud 740c8921a5 Style fixes on bz2 2016-12-20 09:07:15 -08:00
Lukasz Langa 6eb97964fd Fixing flake8 E401, E402 errors 2016-12-20 00:47:51 -08:00
Lukasz Langa 147772950f Fixing flake8 E265 errors 2016-12-20 00:16:44 -08:00
Lukasz Langa 5b6a9937b2 Fixing flake8 E266 errors 2016-12-20 00:06:36 -08:00
Lukasz Langa 67e38b6806 Fixing flake8 E231 errors 2016-12-19 23:53:19 -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
Jelle Zijlstra 918dab66d0 pstats: add stub (#727)
partially addresses #531
2016-12-13 14:51:57 -08:00
Thomas Aynaud 0d7a5374c5 Add missing stubs for bz2 2016-12-12 14:06:10 -08:00
Matthias Kramm 7e6000949e it's threading.Lock, not threading.LockType 2016-12-12 12:02:01 -08:00
Matthias Kramm ac97b22365 add missing Ellipsis 2016-12-12 12:02:01 -08:00
Matthias Kramm 8a5447be05 add 'Handler' and 'Filterer' classes to logging 2016-12-12 12:02:01 -08:00
Philip House 090dafb9b0 fixes #559 (#750) 2016-12-07 13:28:37 -08:00
Jelle Zijlstra 392eb4aa5a add stubs for Python 2 profile and cProfile (#699)
* add stubs for Python 2 profile and cProfile

Partially fixes #531. Contrary to the Python 2.7 docs at
https://docs.python.org/2/library/profile.html#module-cProfile,
these modules do not have exactly the same interface. For
example, profile.Profile() does not have an enable() method.

* profile stubs: move to 2and3, add __init__, use private names for typevars
2016-12-01 11:51:41 +00:00
Lukasz Langa d1081b94ee [logging] Fix forward references 2016-11-30 10:48:10 -08:00
Łukasz Langa 85807ed72a logging.Formatter attributes fixed (#721)
Fixes #720.

Related changes: used a NamedTuple for time.struct_time on Python 3, used
sys.version selectors for proper typing of #716, added missing *Style classes
to logging on Python 3.
2016-11-30 09:09:05 -08:00
Peter Amstutz d0f6a05793 Fix logging.Logger.isEnabledFor() to return bool instead of None. 2016-11-28 13:46:40 -08:00
Naomi Seyfer c134fe7638 handlers should be an optional argument of logging.basicConfig() (#704) 2016-11-24 09:21:10 +00:00
Anders Kaseorg e13f2c739d Add Iterable base class to tarfile.TarFile (#693)
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2016-11-23 11:49:44 +00:00