Commit Graph

191 Commits

Author SHA1 Message Date
Valérian Rousset
a581397c42 add types to logging (#247) 2016-06-04 19:20:15 -07:00
David Euresti
0bfa0636e1 Add http_client to six.moves, add missing functions to urllib2 fix some types in gettext (#262) 2016-06-04 12:02:55 -07:00
David Fisher
49000ccc5e Merge pull request #255 from iamaspacecow/typeshed_calendar_fixes
Update calendar.pyi `timegm` to accept arbitrary length tuples
2016-06-03 17:47:52 -07:00
David Fisher
fb96ee8e50 Revert "replace re patterns AnyStr with Union[str, unicode]"
This reverts commit ba2c8d95ec.
This commit introduced some bugs (it used Pattern[Union[str, unicode]]
when it would need to be Union[Pattern[str], Pattern[unicode]]), and
- on further discussion - it's unclear if we want to allow this
  additional flexibility.  I'm reverting this diff for now, but we'll
revisit this after deciding on the upcoming proposal about how implicit
bytes/unicode conversions should be handled when typing Python 2.
2016-06-03 17:41:01 -07:00
Max Payton
c8f0669ee4 Update calendar.pyi timegm to accept arbitrary length tuples
timegm takes struct_time objects, which are NamedTuples that have 9 elements by default
That would not take Tuple[Int], so typeshed would report errors
2016-06-03 16:10:09 -07:00
Tim Simpson
31a97363a9 Fixes a few tzinfo method's return type (#253) 2016-06-03 12:38:47 -07:00
erinhaswell
2c52d9a612 Correct return value of round in Python 2. (#245)
In Python 2.7, round returns a float, even when ndigits is omitted. In Python 3, round returns an int if ndigits is omitted.
2016-06-02 19:00:20 -07:00
Oren Leaffer
ba2c8d95ec replace re patterns AnyStr with Union[str, unicode] 2016-06-02 17:53:39 -07:00
Valérian Rousset
a32d8a9da6 add types to sys.getrefcount (#237) 2016-06-02 00:27:37 -07:00
Guido van Rossum
25a45d6daf Revert "WIP: Mapping.{get,pop} can return default type (#223)"
This reverts commit d43adbe97e.

Here's a simple example of code that breaks with this PR:

from typing import Mapping, Dict, Tuple
a = {('0', '0'): 42}  # type: Mapping[Tuple[str, str], int]
b = a.get(('1', '1'), 0)

This gives an error on the last line:
error: No overload variant of "get" of "dict" matches argument types [Tuple[builtins.str, builtins.str], builtins.int]
2016-05-30 11:55:30 -07:00
Valérian Rousset
d43adbe97e WIP: Mapping.{get,pop} can return default type (#223)
* Mapping.{get,pop} can return default type

* Mapping values are covariant
2016-05-30 10:05:44 -07:00
Vadim Chugunov
eabecf89d8 Fix setsockopt signature. (#226)
Closes #225
2016-05-26 15:23:31 -07:00
Dakkaron
f32e26ebc2 Added stdlib/2.7/getopt.pyi, updated 3/getopt.pyi (#221)
* Added stdlib/2.7/getopt.pyi

* Small fixes to stdlib/3/getopt.pyi
2016-05-25 07:14:42 -07:00
Jukka Lehtosalo
b98580d299 Don't use basestring in tempfile stub (#205)
Fixes #202.
2016-05-24 16:45:48 -07:00
Guido van Rossum
b6b8554c6b Add stub version of Type[C] (#216) 2016-05-24 16:44:13 -07:00
Dakkaron
25f5c9c6f8 Added type annotations and small fixes (#219)
* json.loads() accepts unicode

* threading.BoundedSemaphore is subclass of Semaphore

* Added type annotations for logging/__init__.pyi and logging/handlers.pyi

* Changed style of variable declaration to fit the rest of the file
2016-05-23 09:16:01 -07:00
David Shea
8503f13a41 Add types for gettext (#217)
* Add empty stubs for gettext Translations subclasses

GNUTranslations and NullTranslations do not add any methods to the base
Translations class, so remove the TODO comment and just declare the
classes.

* Add missing types for py3 gettext.
2016-05-19 14:34:38 -07:00
David Euresti
2bb026cd76 Fix type of getsockopt (#213) 2016-05-18 15:30:24 -07:00
Guido van Rossum
355143851a Use __delete__, not __del__, in class property. See comments on #199. 2016-05-17 11:26:14 -07:00
beckjake
70389d14ee Make property a type (#199) 2016-05-16 13:24:55 -07:00
Guido van Rossum
3e37029bfe Almost all re functions take a compiled pattern. (Even re.compile()!) (#203)
* Almost all re functions take a compiled pattern. (Even re.compile()!)

Fixes #188

Note: I'm using AnyStr so that the type of string used for pattern and
for the rest of the arguments must match.  This is not 100% correct,
since Python 2 sometimes allows mixed types.  But sometimes it
doesn't, depending on the values (e.g. non-ASCII bytes), and Python 3
always insists on matching, so I think this is actually a good idea.

* Same treatment for stdlib/3/re.pyi.
2016-05-16 11:25:59 -07:00
Jukka Lehtosalo
d09cc058a6 Add note about not using basestring in tempfile 2016-05-16 17:46:41 +01:00
Jukka Lehtosalo
d3d6a47302 Accept more unicode in 2.7 tempfile stubs (#201) 2016-05-16 13:37:15 +01:00
Jakub Stasiak
cd12f6e255 Add some missing "type" attributes (#200) 2016-05-14 10:18:36 -07:00
Guido van Rossum
5c881a6b86 Add apply() and coerce() to 2.7 builtins. 2016-05-12 15:50:41 -07: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
detlefla
e2ce50b525 enable string arguments for start, end, and span methods of Match object 2016-05-07 09:53:24 -07:00
Michael R. Crusoe
0be5a11496 A couple new definitions, some more unicode for 2.7 (#185)
* Action.__init__(); ArgumentParser.__init__() & print_help()

* pprint() & pformat()

* added unicode support to url{parse,split,join,defrag}

* add unicode support to requests.api
2016-05-06 09:14:49 -07:00
Ran Benita
eab591bb08 Change datetime.datetime.astimezone tz argument type from timezone to tzinfo (#186)
timezone inherits from tzinfo, so using tzinfo is more general (and e.g.
pytz types inherit directly from tzinfo).

This is the correct type, as quoted from astimezone's code:

    elif not isinstance(tz, tzinfo):
        raise TypeError("tz argument must be an instance of tzinfo")
2016-05-06 08:06:22 -07:00
Jukka Lehtosalo
292447bd62 Misc stub fixes (#181) 2016-05-04 16:54:57 -07:00
Guido van Rossum
c21d8a41d5 Fix 2.7 bisect stubs (lo/hi have defaults). (#182) 2016-05-04 14:46:19 -07:00
David Fisher
e8f626536e Add Python 3 ast module; update Python 2.7 ast module; fixup typed_ast (#170) 2016-05-04 10:40:36 -07:00
Dakkaron
8dff6e481e Added bisect.pyi and ConfigParser.pyi (#171)
* stdlib/2.7./codecs.pyi: added missing __enter__() and __exit__()
* stdlib/2.7/bisect.pyi
* /stdlib/2.7/ConfigParser.pyi
2016-05-04 10:39:52 -07:00
FichteFoll
d492c5360d pprint stream type (#178)
* Use less strict IO[str] instead of TextIO

* IO[Any] should be IO[str]

See also discussion in #17.
2016-05-03 11:48:38 -07:00
rwbarton
2b80cdf75e Use overloading rather than Union for MutableMapping.update (#174)
See https://github.com/python/mypy/issues/1430 for motivation.
2016-05-01 17:50:01 +01:00
Jukka Lehtosalo
a5d5dcc4f4 Fixes to os.environ (#172)
Add os.environ.copy() to Python 2 stubs. Fix return
type of os.environ.copy().
2016-04-28 11:53:51 +01:00
Dakkaron
fde085bbdd stdlib/2.7./codecs.pyi: added missing __enter__() and __exit__() (#167) 2016-04-27 10:23:42 -07:00
Guido van Rossum
79554d6da2 Add type.__call__. Fix #158. (#159) 2016-04-25 16:22:00 +01:00
Linjie Ding
0f67b2a675 Fix Py2 hashlib.new arg type (#157) 2016-04-22 15:35:47 -07:00
Jukka Lehtosalo
8df19841bb Make Queue generic in Python 2, similar to Python 3 (#155) 2016-04-22 15:49:02 +01:00
Jukka Lehtosalo
5eaf522cde Fixes to urllib2 stubs (#154) 2016-04-22 13:19:37 +01:00
David Fisher
a8ef40467d Fix type error in 2.7 stubs (#152) 2016-04-20 14:07:30 -07:00
Michael R. Crusoe
2f59de4713 Change logging signatures to allow unicode (#150) 2016-04-18 09:41:38 -07:00
Ben Darnell
2ddbf901c9 2.7 stub updates (#149)
* Stubgen modules for 2.7

Cookie
email._parseaddr
email.utils
genericpath
linecache
mimetypes
multiprocessing
multiprocessing.process
multiprocessing.util
posixpath
quopri
runpy
weakref
wsgiref.validate

* 2.7/typing.py: add missing __contains__ definition

* 2.7/subprocess.py: make output argument to CalledProcessError optional

Commit f08160bd did the same for py3.

* 2.7/hmac.pyi: add compare_digest

This function was introduced to the 2.7 series in 2.7.7.

* Stubgen 2.7/ssl.pyi

This replaces a nearly-empty handwritten stub.

* Copy constants and other definitions from py3 to py2 ssl.pyi

* 2.7/__future__.pyi: add methods

* 2.7/_weakref.pyi: backport some definitions from 3.x version

* Stubgen 2.7/locale.pyi

Hand-edited to remove declarations that are redundant (and cause
conflicts with) the "from _locale import *" line.
2016-04-17 19:02:55 -07:00
Jukka Lehtosalo
fcef262a9b Support keyword arguments for dict() (Python 2) (#148) 2016-04-17 13:07:54 +01:00
Guido van Rossum
78e6e9b740 Add Text to typing.pyi; it's an alias for unicode in 2.7, for str in 3. 2016-04-16 13:42:17 -07:00
Guido van Rossum
23ec1ff96a Break cycle between typing and collections. (Requires a fix in mypy.) 2016-04-15 21:31:49 -07:00
Katherine Lai
8c59f8f58e Fix select stub for 2.7 (timeout should be optionally present and float) (#135) 2016-04-10 20:46:37 -07:00
Ivan Levkivskyi
db3cc2e8da Enable typing.DefaultDict as an alias for collections.defaultdict (#139) 2016-04-09 09:32:20 -07:00
Matthias Kramm
28dbd6cc6a change ='' to :str=... in httplib 2016-04-08 11:59:34 -07:00