Jelle Zijlstra
db989427cb
dest argument to add_argument is Optional ( #2040 )
...
argparse.py checks for None in _get_optional_kwargs.
2018-04-10 21:47:30 -07:00
Jelle Zijlstra
bdea1bb292
fix third_party/2/enum.pyi ( #2039 )
...
This fixes an error in Travis that seems to have been caused by python/mypy#4319 .
The fix was taken from the stdlib/3.4/enum.pyi stub. Mypy no longer assumes
that classes whose metaclass is EnumMeta are subclasses of Enum, so we can't
bound the typevar on Enum.
2018-04-10 21:34:59 -07:00
Jelle Zijlstra
81a6ea43a5
try using --no-site-packages ( #2036 )
...
Fixes #2035 .
2018-04-09 12:55:18 -07:00
Jelle Zijlstra
f37709f9c3
Merge stubs for sqlite3 ( #2026 )
...
As promised in #2014 .
There are virtually no real changes between Python 2 and 3 in this module, but the stub had accumulated some meaningless differences. I also fixed a few incorrect types.
2018-04-09 12:32:59 -07:00
Jelle Zijlstra
3f456e335e
add multiprocessing.Process.kill and close ( #2027 )
...
See https://docs.python.org/3.7/library/multiprocessing.html#multiprocessing.Process.kill .
Fixes #2022 .
2018-04-09 12:04:14 -07:00
Jelle Zijlstra
d43eac60dd
add email.parser.FeedParser ( #2028 )
...
Fixes #1985 .
2018-04-09 12:03:43 -07:00
Jelle Zijlstra
6862434eae
fix return type for itsdangerous.Signer.unsign ( #2029 )
...
Fixes #2011
Also fixed the argument type (it doesn't accept str).
2018-04-09 12:00:41 -07:00
Jelle Zijlstra
8482b1030b
fill out stubs for requests.structures ( #1897 )
...
Looked at https://github.com/requests/requests/blob/master/requests/structures.py .
The "data" argument to the CaseInsensitiveDict constructor is passed as is to .update(),
so I accept the same argument types as MutableMapping.update.
LookupDict is strangely named and implemented but the point seems to be that you
setattr its keys, and then can access them with both attribute access and subscripting.
See its usage in https://github.com/requests/requests/blob/d1fb1a29ab949223d8d64797e0fcc9a7d2690483/requests/status_codes.py#L102 .
2018-04-06 11:36:43 -07: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
d24799fd31
uncomment a few parts of six.moves ( #2019 )
2018-04-06 11:20:14 -07:00
Jelle Zijlstra
4ab720161a
ResourceWarning doesn't exist in Python 2 ( #2020 )
...
Fixes #1971 .
2018-04-06 11:19:34 -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
0acdfd1548
more 3.7 features ( #2017 )
2018-04-06 11:09:45 -07:00
Jelle Zijlstra
7cfbc7d17f
more 3.7 features ( #2015 )
2018-04-06 11:09:11 -07:00
Jelle Zijlstra
ce0656a8c7
add some more Python 3.7 features ( #2014 )
2018-04-06 11:08:30 -07:00
Jelle Zijlstra
0af84cd9a0
upgrade flake8, pin flake8-pyi version ( #2001 )
...
I'd prefer to pin the exact flake8-pyi version so that test runs are more reproducible.
2018-04-03 07:16:34 -07:00
Jelle Zijlstra
43e6c3c435
add more minor 3.7 new features ( #2000 )
...
part of #1965
2018-03-28 21:28:27 -07:00
Jelle Zijlstra
26e573ba1c
change default value to ... in inspect.pyi ( #1998 )
...
This is in our style guide. This is the last piece of offending code; I just submitted ambv/flake8-pyi#10 to enforce the rule in the linter in the future.
2018-03-28 20:24:39 -07:00
Jelle Zijlstra
5201ccdfff
add E741 to ignored flake8 codes ( #1999 )
...
This was introduced in a recent version (so it doesn't affect us right now but will if we upgrade the flake8 version used in tests). It gives errors like:
```
/home/travis/build/ambv/flake8-pyi/.tox/typeshed/tmp/typeshed/stdlib/3/re.pyi:21:9: E741 ambiguous variable name 'I'
/home/travis/build/ambv/flake8-pyi/.tox/typeshed/tmp/typeshed/stdlib/3/re.pyi:39:5: E741 ambiguous variable name 'I'
/home/travis/build/ambv/flake8-pyi/.tox/typeshed/tmp/typeshed/stdlib/3/re.pyi:58:5: E741 ambiguous variable name 'I'
/home/travis/build/ambv/flake8-pyi/.tox/typeshed/tmp/typeshed/third_party/2/OpenSSL/crypto.pyi:43:5: E741 ambiguous variable name 'O'
```
These aren't useful for typeshed, because regardless of whether it's good style, these libraries really do contain variables named `I` and `O`.
2018-03-28 20:24:24 -07:00
Jelle Zijlstra
371b805c23
improve selenium stubs ( #1732 )
2018-03-28 19:39:43 -07:00
Jelle Zijlstra
0c15e5bdcc
Improve werkzeug stubs ( #1730 )
2018-03-28 19:38:35 -07:00
Jelle Zijlstra
200273edeb
add stub for importlib.resources ( #1993 )
...
Part of #1965
2018-03-28 18:44:40 -07:00
Jelle Zijlstra
103056eecf
fix some TODOs ( #1994 )
...
- Made deque.maxlen read-only
- We don't support 3.2, so we don't care about signature changes in it
- There don't seem to be any missing set operations (I compared the dir() of this class to that of builtins.set)
2018-03-28 18:40:13 -07:00
Jelle Zijlstra
bbbffb5f4b
implement some minor 3.7 features ( #1966 )
...
References:
- https://docs.python.org/dev/library/datetime.html#datetime.datetime.fromisoformat
- https://docs.python.org/dev/library/crypt.html#crypt.mksalt
- https://docs.python.org/dev/library/contextlib.html#contextlib.AbstractAsyncContextManager
- https://docs.python.org/dev/library/calendar.html#calendar.HTMLCalendar.cssclasses
- https://docs.python.org/dev/library/binascii.html#binascii.b2a_uu
Part of #1965 .
2018-03-22 08:01:09 -07:00
Jelle Zijlstra
b9c5e811df
allow instantiating TracebackType in 3.7 ( #1967 )
...
See https://docs.python.org/dev/reference/datamodel.html#traceback-objects
and python/cpython#4793.
part of #1965
2018-03-21 15:26:23 -07:00
Jelle Zijlstra
bfe0b06953
add stub for contextvars.pyi ( #1968 )
...
Part of #1965 .
2018-03-21 15:16:14 -07:00
Jelle Zijlstra
35d3effe03
Remove version check for deque.insert and deque.index ( #1916 )
...
Otherwise, deque is not instantiable in Python 3.4. We could do a dynamic base class instead
but that doesn't seem worth it.
2018-02-24 11:12:56 -08:00
Jelle Zijlstra
ab72267669
also test 3.7 with mypy ( #1917 )
2018-02-24 09:56:35 -08:00
Jelle Zijlstra
fe4bea39a2
fix return type of linecache.getlines ( #1877 )
...
Randomly noticed this looking at the stub. Here is the code: https://github.com/python/cpython/blob/3.7/Lib/linecache.py#L37 .
2018-02-13 16:19:44 -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
fb2c7b34e2
Improve itsdangerous stubs ( #1733 )
2018-01-02 12:50:22 -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
Jelle Zijlstra
6509eee80e
add util.pyi to blacklist ( #1800 )
2017-12-23 11:23:49 -08:00
Jelle Zijlstra
0eb7083f0e
move dateutil into 2and3 ( #1743 )
...
These stubs are identical since #1735 .
2017-12-23 06:38:55 -08:00
Jelle Zijlstra
533a05be45
Fix some of the last default values that are not ... ( #1731 )
...
* still one left in atomicwrites that I need to investigate further
* fix atomicwrites
2017-11-13 07:08:30 -08:00
Jelle Zijlstra
69bffd154a
Fix default values in click stubs to ... ( #1734 )
2017-11-13 07:07:20 -08:00
Jelle Zijlstra
8e75701eda
make Python 2 and 3 dateutil stubs identical ( #1735 )
...
So that they can be merged into 2and3. This PR also adds a few missing
elements to parser.pyi and corrects some mistakes in the Python 3 stub.
Refer to https://github.com/dateutil/dateutil/tree/master/dateutil
2017-11-13 07:06:34 -08:00
Jelle Zijlstra
84d0cbf776
move thrift to 2and3 ( #1736 )
...
thrift supports Python 3 as of version 0.10.0. These stubs are pure stubgen and
might not be much good, but they belong in 2and3.
2017-11-13 07:05:57 -08:00
Jelle Zijlstra
bcfd3bf554
Fill out croniter stubs and move to 2and3 ( #1737 )
...
* fill out croniter stub
* move to 2and3
2017-11-13 07:05:38 -08:00
Jelle Zijlstra
83ca997140
Change more defaults to ... ( #1729 )
...
* codemod ': Any = None' ': Any = ...'
* codemod ': (Union|Optional)([^=]+)\s+=\s+-?\d+' ': \1\2 = ...'
* codemod ': (Union|Optional)([^=]+)\s*=\s*-?(None|False|True)' ': \1\2 = ...'
* codemod ': (int|float|bool)\s*=\s*-?\d+' ': \1 = ...'
* codemod ': (bool)\s*=\s*(False|True)' ': \1 = ...'
* codemod ': Any\s*=\s*(False|True|None)' ': Any = ...'
2017-11-13 06:56:24 -08:00
Jelle Zijlstra
0080017d02
fill out bz2 stub ( #1728 )
...
- add a default value to ...
- add some missing version checks
- add some missing arguments
2017-11-13 06:55:43 -08:00
Jelle Zijlstra
97be335160
don't import enum in Python 2 ( #1724 )
...
* don't import enum in Python 2
Fixes a pytype issue from #1720 .
* move enums together
2017-11-10 10:23:22 -08:00
Jelle Zijlstra
9390a49600
complete multiprocessing.connection stub ( #1716 )
...
Adds additional public members based on https://github.com/python/cpython/blob/master/Lib/multiprocessing/connection.py#L10 and https://docs.python.org/3/library/multiprocessing.html#multiprocessing-listeners-clients .
I found some discrepancies in the docs while adding these stubs and filed python/cpython#4304 to address them.
2017-11-09 10:40:49 -08:00
Jelle Zijlstra
324f1761f4
Change more defaults to ... ( #1727 )
2017-11-09 10:32:17 -08:00
Jelle Zijlstra
54dd6ba27c
Change numerous default values to ... ( #1722 )
...
This is the convention, and some default values (e.g. strings) apparently
break pytype.
2017-11-09 06:28:40 -08:00
Jelle Zijlstra
eaf8972e48
complete Python 3 gzip stub ( #1723 )
...
* complete python 3 gzip stub
* IOBase.closed is read-only
2017-11-09 05:56:55 -08:00
Jelle Zijlstra
735abe68dd
remove all lxml stubs for now ( #1664 )
...
Fixes #525 .
2017-11-07 07:54:01 -08:00
Jelle Zijlstra
c10dc67ad2
Re-export names in dateutil.tz ( #1669 )
...
Fixes #1665 .
2017-10-12 17:57:12 -07:00
Jelle Zijlstra
b54a711778
Recommend against creating incomplete stubs ( #1659 )
...
I disagree with the recommendation that users create incomplete stubs, because such stubs lead to false positive type checker errors (see for example #525 ). I would like to instead set a norm that all stubs should contain all public objects in the library they cover.
2017-10-10 08:27:47 -07:00
Jelle Zijlstra
78587dc895
Revert "make __class__ refer to the current object's class ( #1549 )" ( #1632 )
...
This reverts commit 1a164b630c .
Reverts python/typeshed#1549 .
See Guido's comments in the original PR.
2017-09-29 11:37:54 -07:00
Jelle Zijlstra
1a164b630c
make __class__ refer to the current object's class ( #1549 )
...
Fixes python/mypy#3061
2017-09-27 18:11:59 -07:00
Jelle Zijlstra
4ea6c1cffb
sys: clean up ( #1545 )
...
- More precise types for trace and profile functions
- Remove redundant comments
2017-08-21 13:54:55 -07:00
Jelle Zijlstra
c40b7afc14
accept PathLike in os.scandir ( #1546 )
2017-08-21 13:54:22 -07:00
Jelle Zijlstra
5c328f12e1
configparser: support PathLike ( #1547 )
...
RawConfigParser.read has code explicitly supporting PathLike objects.
Also removed an unused import and widened the accepted type from
Sequence to Iterable.
2017-08-21 13:42:35 -07:00
Jelle Zijlstra
e20a36ada2
add to CONTRIBUTING ( #1560 )
...
Ask contributors to better explain their changes and link to documentation and code. These things generally make pull requests easier to review.
2017-08-21 13:26:00 -07:00
Jelle Zijlstra
d60f26c448
add object.__dir__ in Python 3 ( #1532 )
...
In Python 3 (but not Python 2), `object().__dir__()` works and returns a list of strings.
This is relevant when implementing a custom `__dir__` that invokes `super().__dir__()`.
2017-08-07 19:29:13 -07:00
Jelle Zijlstra
2d97894fa9
collections: make UserDict, UserList, and UserString concrete ( #1477 )
...
* collections: make UserDict, UserList, and UserString concrete
* add version checks
https://github.com/python/cpython/commit/573b44c18f69307d7dbc95c950aab57ef7ea303e
* remove redundant methods
2017-07-26 16:34:43 -07:00
Jelle Zijlstra
be7490322b
Counter: fix return value of most_common() ( #1491 )
...
https://docs.python.org/3/library/collections.html#collections.Counter.most_common
https://docs.python.org/2/library/collections.html#collections.Counter.most_common
2017-07-19 20:29:32 +03:00
Jelle Zijlstra
00ddb1c84a
encodings: IncrementalEncoder and Decoder concrete ( #1490 )
...
These stubs are identical in Python 2 and 3, but I believe they
should not be merged, because there are numerous other modules
in the encodings package, and some only exist in some Python
versions. I don't think we can support that in the 2and3
directory.
2017-07-19 20:28:43 +03:00
Jelle Zijlstra
32d9c8cb8f
make io.IncrementalNewlineDecoder concrete ( #1489 )
...
Part of #1476
2017-07-19 20:28:25 +03:00
Jelle Zijlstra
74966bacd9
distutils: make Command classes non-abstract ( #1488 )
2017-07-19 20:28:16 +03:00
Jelle Zijlstra
ac651d2f8c
Fix a few TODOs ( #1487 )
...
* fix some easy TODOs
* fix io
2017-07-19 20:27:50 +03:00
Jelle Zijlstra
1515ed9f88
fix some abstract classes in third_party/ ( #1486 )
2017-07-19 20:27:22 +03:00
Jelle Zijlstra
0e26c1f936
asyncio: fix several types ( #1450 )
...
Fixes #1447
2017-07-06 14:22:55 -07:00
Jelle Zijlstra
16aa0651ae
Revert "Add __new__ to str and int stubs in both Pythons. ( #1352 )" ( #1466 )
...
This reverts commit fed4e03e53 .
2017-07-06 14:21:54 -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
7ecc979211
locale: broaden type of val argument to format ( #1453 )
...
Fixes #1350
2017-07-04 19:21:12 -07:00
Jelle Zijlstra
f264eda4ed
builtins: mode argument to open can be unicode ( #1452 )
...
Part of #1411
Also remove some explicit parameter defaults.
2017-07-04 19:20:45 -07:00
Jelle Zijlstra
9947c9d513
urlparse: allow unicode arguments in more places ( #1451 )
...
* urlparse: allow unicode arguments in more places
Part of #1411
urlunsplit() and similar functions accept either unicode or str in all
places. Their actual return type is unicode if any of the arguments is
unicode and nonempty, which the type system can't exactly express. I
left the return type as str because str is implicitly promoted to
unicode, so using the return type in a place that accepts unicode should
work.
unquote, parse_qs, and parse_qsl return unicode if you pass them unicode,
so AnyStr is appropriate in their stubs.
* fix type for urldefrag
The return type was wrong; this function returns a 2-tuple. The second member of the tuple is always a `str` if the argument type does not contain '#', and otherwise matches the type of the argument.
2017-07-04 19:20:23 -07:00
Jelle Zijlstra
fee2eaae30
xml.sax.saxutils: make some functions take AnyStr ( #1457 )
...
Fixes #1062
2017-07-04 19:18:43 -07:00
Jelle Zijlstra
2b97c02801
logging: make Logger inherit from Filterer ( #1448 )
...
Fixes #1401
2017-07-04 19:18:01 -07:00
Jelle Zijlstra
e980c8987b
tokenize: add generate_tokens in py3 ( #1449 )
...
Fixes #1433
This is undocumented but somebody is asking for it to be included.
2017-07-04 19:17:39 -07:00
Jelle Zijlstra
22f47fd478
add typing.AsyncContextManager and contextlib.asynccontextmanager ( #1432 )
...
Implements:
- https://github.com/python/typing/pull/438
- https://github.com/python/cpython/pull/360
Note that https://github.com/python/cpython/pull/1412 , which adds
contextlib.AbstractAsyncContextManager, has not yet been merged.
2017-06-27 10:39:40 -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
Jelle Zijlstra
9bbcb0822d
add difflib.diff_bytes and difflib.Match ( #1336 )
2017-05-26 09:32:34 -07:00
Jelle Zijlstra
f8d06c88e5
fix reverse comparison in optparse ( #1337 )
2017-05-26 09:31:30 -07:00
Jelle Zijlstra
296f294b75
add fileinput.filelineno and fileinput.fileno ( #1338 )
2017-05-26 09:30:42 -07:00
Jelle Zijlstra
d23fe74072
add some exception classes to shutil ( #1334 )
2017-05-26 09:30:20 -07:00
Jelle Zijlstra
e8013fd808
add types.AsyncGeneratorType ( #1322 )
2017-05-26 08:37:39 -07:00
Jelle Zijlstra
fefdf185c7
merge and complete linecache stubs ( #1320 )
2017-05-26 08:30:42 -07:00
Jelle Zijlstra
4f2dd0f446
remove unused type ignore flags ( #1346 )
...
Verified that none of those are necessary for pytype.
2017-05-26 08:28:51 -07:00
Jelle Zijlstra
c31dcf4088
Add more flags to socket ( #1348 )
...
Also switch to PEP 526-style types in socket.
2017-05-26 08:25:20 -07:00
Jelle Zijlstra
2800002ebf
add to calendar stub ( #1359 )
2017-05-26 06:27:08 -07:00
Jelle Zijlstra
aeb19baa84
add symtable.symtable ( #1360 )
...
https://docs.python.org/3/library/symtable.html#symtable.symtable
and
https://docs.python.org/2/library/symtable.html#symtable.symtable
2017-05-25 19:39:15 -07:00
Jelle Zijlstra
3ed17cdb49
distutils.core.setup fixes ( #1358 )
...
- add include_package_data (which setuptools accepts)
- allow arbitrary other kwargs, because distutils.core.setup allows arbitrary kwargs and just passes them through to commands
2017-05-25 19:37:10 -07:00
Jelle Zijlstra
c4e6ce319f
minor fixes to email stubs ( #1357 )
2017-05-25 19:36:48 -07:00
Jelle Zijlstra
72a745b2f8
remove collections.MutableString ( #1356 )
...
It does not exist (some StackOverflow question I found suggests it was removed in 2.6).
2017-05-25 19:36:08 -07:00
Jelle Zijlstra
fce4424c6e
add http.client.error ( #1355 )
...
It's in __all__
2017-05-25 19:35:36 -07:00
Jelle Zijlstra
a25b449ee0
add some missing classes and platform checks to socketserver ( #1354 )
...
These checks were already in SocketServer.pyi for Python 2.
2017-05-25 19:34:27 -07:00
Jelle Zijlstra
26d1ff8352
add tempfile.TMP_MAX for py3 ( #1353 )
2017-05-25 19:33:05 -07:00
Jelle Zijlstra
875b02e374
complete and merge weakref stubs ( #1343 )
2017-05-24 20:35:16 -07:00
Jelle Zijlstra
383d1dc9e1
mark cProfile as private in pstats.pyi ( #1344 )
2017-05-24 20:33:20 -07:00
Jelle Zijlstra
d9bf214203
merge pickle stubs into 2and3 ( #1328 )
...
Followup from #1321
2017-05-24 14:57:58 -07:00
Jelle Zijlstra
6fe7cdb1c3
merge 2and3 stubs for select ( #1333 )
...
There don't seem to be significant changes between Python 2 and 3. The Python 2
stub was much better, so I mostly built off of it.
2017-05-24 14:57:11 -07:00
Jelle Zijlstra
6152bad0af
add random.choices for 3.6 ( #1329 )
2017-05-24 14:09:52 -07:00
Jelle Zijlstra
89f27742ca
add re.template ( #1330 )
2017-05-24 14:07:31 -07:00
Jelle Zijlstra
890190d349
add opcodes to pickle stubs ( #1321 )
2017-05-24 08:05:55 -07:00
Jelle Zijlstra
97f32a57a2
complete __future__ stubs ( #1326 )
...
We were missing the most important one.
2017-05-24 08:02:47 -07:00
Jelle Zijlstra
5e4165493a
fix typo in importlib.abc ( #1323 )
2017-05-24 08:00:12 -07:00