Commit Graph
72 Commits
Author SHA1 Message Date
Matthias Kramm 6c30806d07 add deprecation comment to mypy_extensions (#1943) 2018-03-05 18:51:14 -08:00
Matthias Kramm 9c04490e92 add sys.setdefaultencoding() (#1865) 2018-02-08 11:25:48 -08:00
Matthias Kramm 72052d8338 Fix tests to work with newest version of pytype (#1824) 2018-01-12 12:28:19 -08:00
Matthias Kramm 03ec4023ff Adjust ast imports to make pytype happy. (#1617)
Turns out that pytype is a bit more finicky about imports, and
differentiates between '*' imports for export, and imports
for use in the local pyi. This adjusts ast.pyi to make pytype
understand it again.
2017-09-22 06:27:27 -07:00
Matthias Kramm 3638bc1f52 Fix Python 2's traceback.format_exception, traceback.print_exception (#1512)
E.g. it's legal to call traceback.format_exception(None, None, None). In
particular, this change makes the following idiom type-check:
  import traceback
  import sys
  exc_type, exc_value, exc_traceback = sys.exc_info()
  traceback.format_exception(exc_type, exc_value, exc_traceback)
2017-08-03 15:58:34 -07:00
Matthias Kramm 6f23d124c0 Remove subclass IOBase from TextIOBase. (#1505)
This used to cause TextIOBase to subclass both BinaryIO and TextIO, even
though those two are incompatible.
2017-07-28 21:07:37 -07:00
Matthias Kramm a5d044361b Add "conventions" section to README.md (#1470)
This documents, among others, the unicode -> Union[bytes, unicode] promotion that python/peps#302 removes from PEP 484.
2017-07-18 13:58:24 -07:00
Matthias Kramm c4e0580a4a make io.pyi import everything from _io.py(i), like io.py does (#1395)
* 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
2017-06-21 20:04:04 -07:00
Matthias Kramm 5d1aacfed3 special-case overload for itertools.product with 'repeat' (#1410)
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.
2017-06-15 19:13:46 +01:00
Matthias Kramm d5e7663f93 add back 'repeat' argument to itertools.product (#1407)
Fixes a regression introduced by #1393.
2017-06-14 09:33:37 -07:00
Matthias Kramm 6849262df6 add _levelNames to logging/__init__.py (#1404)
* add _levelNames to logging/__init__.py

* add Python 3's _levelToName and _nameToLevel
2017-06-13 08:26:14 -07:00
Matthias Kramm ed6dc176da make itertools.product more precise (#1393) 2017-06-12 20:10:08 -07:00
Matthias Kramm d4c13e73f9 gzip.GzipFile.__init__ accepts any Text for 'mode' (#1403) 2017-06-12 15:36:47 -07:00
Matthias Kramm a02f9b6d46 switch order of ContextManager and Generic (#1382)
Since ContextManager inherits from Generic, too, listing Generic first, in the list of base classes, results in a cyclic MRO.
2017-06-01 18:06:43 -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
Matthias Kramm ac0b809bf5 tweak files to fix pytype parsing errors (#1325)
* Don't use "\" to join lines
2017-05-26 08:45:52 -07:00
Matthias Kramm 8d8708594e Make sys.modules a Dict[str, Any] (#1266)
* Add __getattr__ to ModuleType.

Modules can contain anything, so give them a generic "__getattr__(name) -> Any".
This makes code like the following type-check, in pytype:
    sys.modules.get("random").randint

* undo Python 3 change

* Revert "undo Python 3 change"

This reverts commit 96cf2d529e374a754f1ba681f0fc81aab25f81ef.

* Revert "Add __getattr__ to ModuleType."

This reverts commit 3ac1cf8a3b25dabfe386fbf34aef680fb1acd112.

* In stdlib/2/, make sys.modules a Dict[str, Any].

(Instead of Dict[str, ModuleType])
Same as stdlib/3/.
2017-05-20 11:08:25 -07:00
Matthias Kramm d7d27647a9 also run pytype tests for Python 3 modules (#1278) 2017-05-20 09:10:14 -07:00
Matthias Kramm 8d8a34cb83 Patch from @sfreilich: make itertools.ifilter predicate parameter Optional (#1257)
From Samuel Freilich:
In Python 2, the predicate parameter in itertools.ifilter and
itertools.ifilterfalse can be None, indicating that true or false values
should be retained (functionally equivalent to passing "bool" as the
predicate). In Python 3, filter and itertools.filterfalse have
the same behavior.
2017-05-09 17:50:11 -07:00
Matthias Kramm 7e58389a27 a better definition for io.IOBase (#1160)
* a better definition for io.IOBase

* move BinaryIO superclass into _io._IOBase

* remove write() from _TextIOBase
2017-04-17 09:42:59 -07:00
Matthias Kramm 8b50522273 md5.md5(string) (#1119)
* md5.md5(string)

* switch md5 from str to AnyStr, add missing constants

* add missing import

* digest() and hexdigest() never return unicode

* make md5.md5 an alias of, and fix, hashlib_hash

* remove unnecessary import

* fix duplicate block_size

* md5.md5 and md5.new are aliases for hashlib.md5
2017-04-02 15:01:17 -07:00
Matthias Kramm 02bd2bdf69 Make pickle accept IO[str] instead of BinaryIO. (#980)
* Make pickle accept IO[str] instead of BinaryIO.

This makes the following code work:
pickle.Unpickler(cStringIO.StringIO())
(Which didn't work before because cStringIO.StringIO inherits "only"
 from IO[str], not BinaryIO)

* Use bytes instead of str.
2017-03-10 20:24:20 -08:00
Matthias Kramm f869a5d351 fix bugs in stdlib/2/csv.py (#932) 2017-02-13 20:21:19 -08:00
Matthias Kramm 7a211921dd asctime/strftime take a tuple, too (#921) 2017-02-07 16:22:47 -08:00
Matthias Kramm b240b241f0 add stdlib/2/repr.pyi (#910) 2017-01-31 14:56:48 -08:00
Matthias Kramm 6855a20a51 add TestCase.failureException (#907) 2017-01-31 14:37:52 -08:00
Matthias Kramm 295ffbe4f3 improve inspect.pyi (#908) 2017-01-31 14:34:18 -08:00
Matthias Kramm 293dcfa661 fix socket.sendto (#909) 2017-01-31 14:32:15 -08:00
Matthias Kramm 79061f9de2 move simplejson from stdlib/ to third_party/ (#752) 2016-12-06 17:43:47 -08:00
Matthias Kramm a2559eeaeb make pytype aware that 2.7/ has been renamed to 2/ (#729) 2016-12-02 06:10:14 -08:00
Matthias Kramm 3253d3cc46 Add more methods to return type of tempfile.{,Named,Spooled}TemporaryFile(). (#623) 2016-10-19 16:07:03 -07:00
Matthias Kramm df6aeef9fd Add missing methods to 2.7/posixpath.pyi. (#622) 2016-10-19 15:53:36 -07:00
Matthias Kramm 7d80824092 Better definition for xml/sax/__init__.pyi. (#621)
Also, merge 2.7/xml/sax and 3/xml/sax into 2and3/xml/sax.
2016-10-19 15:30:25 -07:00
Matthias Kramm 94d3ddb60a change the way 'os' imports 'os.path' (#601)
* use 'from . import path' instead, in both PY2 and PY3
* update blacklist to include os/__init__.pyi
2016-10-17 17:49:12 -07:00
Matthias Kramm b0eae4bf46 allow to use RLock in type annotations (#595) 2016-10-10 16:52:47 -07:00
Matthias Kramm ccd1dc1fac fix 2.7 version of Logger.debug (#578) 2016-09-29 12:02:12 -07:00
Matthias Kramm 76c0850eb2 Use the correct __builtin__/builtins module in Python 2/3. (#569) 2016-09-23 05:38:35 -07:00
Matthias Kramm 7a7873aa94 adjust pytype blacklist (#529)
Remove argparse, tarfile and logging/handlers.
2016-09-09 12:28:54 -07:00
Matthias Kramm e70be5fbe2 trim pytype testing blacklist (#527) 2016-09-09 06:30:36 -07:00
Matthias Kramm 044d11f9ee clean up unittest.py (#509)
* clean up unittest.py

Remove duplicates, adjust wrapping.

* also remove unittest from pytype blacklist
2016-08-31 07:27:53 -07:00
Matthias Kramm c46993aa8e Add mypy blacklist, same syntax as pytype blacklist. (#508) 2016-08-29 14:23:39 -07:00
Matthias Kramm 395265b9fb trim blacklist (#370)
Remove files that now work with pytype from blacklist.
2016-07-15 10:17:47 -07:00
Matthias Kramm cfeaa41310 Merge pull request #359 from Michael0x2a/add-boto-exception-stub
Add stub for boto.exception
2016-07-12 17:18:26 -07:00
Matthias Kramm e19e10c891 Merge pull request #348 from sharmaeklavya2/fix-subprocess-check-output
subprocess: Fix return type of check_output.
2016-07-12 17:12:33 -07:00
Matthias Kramm 6f5e20dcd4 Merge pull request #358 from alvarocaceres/fixup
revert unnecessary change to mypy_test from previous commit
2016-07-12 17:01:17 -07:00
Matthias Kramm b48ddf7532 Merge pull request #352 from tharvik/improve_argparse
merge py2 and py3 argparse
2016-07-11 06:36:25 -07:00
Matthias Kramm 90b9d4d77c Merge pull request #339 from tharvik/improve_os
add some types to os
2016-07-11 06:18:38 -07:00
Matthias Kramm 9e432889fe Merge pull request #351 from tharvik/fix_bytearray
add bytearray.insert
2016-07-11 06:07:02 -07:00
Matthias Kramm 6248885ccc Merge pull request #350 from sharmaeklavya2/fix-bytearray
__builtin__: Fix bytearray on python 2
2016-07-08 14:11:45 -07:00
Matthias Kramm 0c75a22ffb Merge pull request #303 from sharmaeklavya2/sort-cmp
Add cmp to list.sort in python 2.7
2016-07-07 13:22:49 -07:00
Matthias Kramm 8f4a4b7817 Merge pull request #347 from fyquah95/master
Add stdlib/2.7/traceback._print
2016-07-07 09:33:12 -07:00
Matthias Kramm f75bbae18d Merge pull request #344 from tharvik/improve_unittest
improve unittest
2016-07-07 06:36:06 -07:00
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
Matthias Kramm c5d67e155f Merge pull request #322 from amitsaha/stringio_len
stdlib: StringIO - Add len attribute issue #316
2016-06-30 05:52:17 -07:00
Matthias Kramm 8ff5d7b7e2 Merge pull request #306 from haakenlid/master
add stub for stdlib abc.ABC in python 3.4+ (issue #304)
2016-06-20 09:25:11 -07:00
Matthias Kramm 37bc4987be Merge pull request #299 from alvarocaceres/csv
csv module: make reader() and writer() return types private and non-abstract
2016-06-15 15:01:28 -07:00
Matthias Kramm af057ecb7b Merge pull request #298 from alvarocaceres/attributes
Use "..." for attribute values, instead of None, [], {}
2016-06-15 14:02:01 -07:00
Matthias Kramm 9ff4bc1f60 Merge pull request #142 from smarkets/bz2-stub
Add a very basic bz2 stub
2016-04-13 07:51:20 -05:00
Matthias Kramm 335ef31893 Merge pull request #85 from ddfisher/master
Remove invalid Python 3 syntax
2016-02-23 20:14:15 -06:00
Matthias Kramm 3ba178ddc4 Merge pull request #67 from howardzlee/frozenset
Copy frozenset stubs from 3/builtins.pyi into 2.7/__builtin__.pyi.
2016-01-27 14:56:11 -08:00
Matthias Kramm 69169765a7 Merge pull request #55 from timabbott/tabbott-re
Add missing re module constants for 2.7.
2016-01-25 12:44:14 -08:00
Matthias Kramm 23adcaf4f4 Merge pull request #54 from ismail-s/patch-1
Implement fromhex and maketrans method
2016-01-25 08:06:59 -08:00
Matthias Kramm c957fc9f17 Merge pull request #53 from timabbott/mutable
Fix os.environ improperly classified as not mutable for python 2.
2016-01-22 21:33:01 -08:00
Matthias Kramm 129bf57659 Merge pull request #40 from rmcgibbo/lru_cache
Enhance type information for lru_cache
2016-01-11 05:55:32 -08:00
Matthias Kramm cff4aa066b Merge pull request #34 from catch22/patch-2
Update random.pyi
2015-12-30 13:21:23 -08:00
Matthias Kramm 28e1cbec46 Merge pull request #33 from catch22/patch-1
Update shlex.pyi
2015-12-30 13:04:28 -08:00
Matthias Kramm a3987c09e6 Merge pull request #32 from gnprice/sequence
Sequence: match 2 to 3 in typing, remove redundant base classes in builtins
2015-12-22 05:50:56 -08:00
matthiaskramm c0493bd3d0 Merge pull request #31 from gnprice/operator
operator: share in 2and3, and make attrgetter and friends usable
2015-12-17 15:31:48 -08:00
matthiaskramm 63e441e804 Merge pull request #23 from o11c/six-no-moves
Six without six.moves
2015-10-29 13:11:43 -07:00
matthiaskramm 7ccc71aa85 Merge pull request #20 from o11c/builtin
Fix name of the builtin module in python2
2015-10-20 10:03:45 -07:00
matthiaskramm ee1930d861 Merge pull request #15 from o11c/lots
Lots of stub fixes
2015-10-20 07:17:17 -07:00
matthiaskramm c30fb8a6df Merge pull request #11 from kirbyfan64/kirbyfan64-patch-1
Fix link to PEP 484
2015-05-03 09:18:54 -07:00