Commit Graph

97 Commits

Author SHA1 Message Date
Semyon Proshev
8c1690befc Update stubs for classmethod and staticmethod in both Pythons. (#1089) 2017-03-29 10:19:17 -07:00
George King
18cc2cbf8c Add correct optional default start/end parameters to str count, find, index, rfind, rindex. (#1109)
fixes #1108
2017-03-28 10:11:50 -07:00
Nathan Henrie
fb80dc3971 Add ModuleNotFoundError for Python >= 3.6 (#1083)
6f0eb93183/Objects/exceptions.c (L707)
https://docs.python.org/3/library/exceptions.html#ModuleNotFoundError
2017-03-23 18:16:53 -07:00
Semyon Proshev
78d0cc32df Add __new__ to builtin dict (#1056) 2017-03-22 07:33:06 -07:00
Guido van Rossum
7587e7f1c1 Make PathLike generic in AnyStr (#1060) 2017-03-21 14:33:22 -07:00
Guido van Rossum
41561f11c7 Redo PathLike without importing os into builtins. 2017-03-21 10:50:10 -07:00
Guido van Rossum
baa61a151b Revert "Update stub for builtin open function due to PEP-519."
This reverts commit 48b271c862.

See https://github.com/python/typeshed/pull/991#issuecomment-288160993
for details; basically this disturbed mypy's bootstrap import cycle.
2017-03-21 10:45:06 -07:00
Ivan Levkivskyi
ed9f70c738 Replace frozenset with FrozenSet (#1057) 2017-03-21 07:52:34 -07:00
Jelle Zijlstra
25464cf0a7 Merge pull request #991 from JetBrains/sproshev/pep-519
Update `open`, `os.fspath`, `os.fsencode`, `os.fsdecode`, `pathlib.PurePath` and `pathlib.Path` stubs due to PEP-519
2017-03-21 07:38:50 -07:00
David Euresti
2fdcd2e9e8 Let MutableMapping.pop take a different default type. (#1044)
This is particularly useful for the idiom `d.pop(k, None)` to remove an item if it exists.

Fixes #278
2017-03-20 12:10:38 -07:00
Semyon Proshev
25c66a011e Add zip stubs for 5 and more arguments. (#1041)
* Add `zip` stubs for 5 and more arguments.

* Update `zip` stubs for 6+ arguments.
2017-03-20 11:38:38 -07:00
David Euresti
d43f3be914 Unify stdlib/{2,3}/typing.pyi
Also fix signature of IO.seek, IO.truncate, IO.write, and MutableMapping.update
Fixes #1016

Note: I couldn't put typing.pyi in 2and3 because of an import cycle when adding `import sys` to 2/typing.pyi
2017-03-19 09:43:40 -07:00
Semyon Proshev
4cd137189a Remove object as the only ancestor for classes in Python 3 stubs. 2017-03-18 14:57:57 -07:00
Tadeu Manoel
da6d4314d3 Add missing method 'indices' in 'slice' builtin (#1007) 2017-03-16 09:18:24 -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
=^_^=
45f4a1e913 Allow nested tuples in isinstance/issubclass (#998)
Fixes #997
2017-03-14 08:04:12 -07:00
Ivan Levkivskyi
b430318ac0 Fix non-subscriptable type aliases (#993) 2017-03-13 17:24:34 -07:00
Semyon Proshev
48b271c862 Update stub for builtin open function due to PEP-519. 2017-03-13 18:33:02 +03:00
Ivan Levkivskyi
0bf23b3727 Add __annotations__ to Python 3 (#990) 2017-03-13 07:38:38 -07:00
Jelle Zijlstra
555f45b876 remove "return" statements from builtins.pyi (#986)
Type checkers shouldn't care that these methods are returning the same object.
2017-03-12 19:33:29 -07:00
Ivan Levkivskyi
bd5b33f3b1 Fix frozenset (#979) 2017-03-10 13:59:32 -08:00
Andrey Vlasovskikh
295788b672 Missing special attributes of class instances inherited from object (#943)
* Missing special attributes of class instances inherited from object
* object.__reduce__ returns a tuple

It's up to its inheritors to return either a tuple or a string.
2017-02-20 11:50:14 -08:00
Andrey Vlasovskikh
7212f23f7b Added missing 'property' attributes 2017-02-20 11:04:27 -08:00
Andrey Vlasovskikh
43c1369901 More precise type for 'slice' constructor
start and stop arguments are required even though they can be None.
2017-02-20 11:03:30 -08:00
5j9
f192b8c784 Update count, (r)find, and (r)index type hints for bytes and bytearray (#923)
The above methods have changed in version 3.3 to also accept an integer in
the range 0 to 255 as the subsequence.

Fixes python/mypy#2831
2017-02-08 15:21:41 -08:00
Andrey Vlasovskikh
bb33cb0119 Added __instancecheck__ and __subclasscheck__ to type (#887) 2017-01-29 11:17:01 -08:00
Andrey Vlasovskikh
8ce64ce782 Updates to slice built-in (#891)
Makes args and attributes optional.
2017-01-29 11:16:23 -08:00
Andrey Vlasovskikh
2b25b3ef6d Argument of input() is not restricted to str (#890) 2017-01-29 10:34:32 -08:00
Andrey Vlasovskikh
c8435f4315 Added object.__sizeof__ (#865)
* Added object.__sizeof__

* Removed __sizeof__ inherited from object

* Made sqlite3 classes for Python 2 inherit from object

* Removed __sizeof__ inherited from object
2017-01-26 12:05:53 -08:00
Andrey Vlasovskikh
025f31dcc9 Added class super to builtins (#867) 2017-01-26 11:53:59 -08:00
Alex Frieder
cf98162fca Add __bool__ to numeric builtin types 2017-01-20 12:41:16 -08:00
Jukka Lehtosalo
f2579e532f Update signature of dict.get (#852)
Without this change, mypy can't infer proper types for cases like
`d.get(k, [])` where it needs type context to infer the type of
`[]`. We add the value type to the second argument to `get` using
union types, and this provides the context. This doesn't affect
the effective signature of `get`, other than providing the type
context for mypy.

Also removed some related redundant method definitions where we can
just inherit the base class definition. This makes it easier to
keep the method signatures consistent.

Note that this requires a few mypy PRs before mypy will be able to
use this effectively:

* https://github.com/python/mypy/pull/2718
* https://github.com/python/mypy/pull/2715
2017-01-20 07:41:54 -08:00
Dylan Jenkinson
6339f88ae4 Updated the stub for builtins to change slice to take Optional[int] rather than just straight int. 2017-01-18 11:30:41 -08:00
Roy Williams
41ba734fc2 Fix return type of next when default parameter is provided.
**test_next.py**:
```python
z = (x*2 for x in range(10))
reveal_type(next(z, None))
```

Before:
```shell
test_next.py:2: error: Revealed type is 'builtins.int*'
```

After:
```shell
test_next.py:2: error: Revealed type is 'Union[builtins.int*, builtins.None]'
```
2017-01-13 09:46:51 -08:00
Roy Williams
6008b9dbb1 Overload signature of get to return an Optional value and to allow default to take any type to match runtime behavior.
This chage more closely matches the behavior of `get` at runtime.  Users can pass whatever they want in to the default
parameter and it will be returned if the key is absent.  Additionally, `get` should return an `Optional` if called with
only one parameter.

```python
z = {'a': 22}
reveal_type(z.get('b'))
reveal_type(z.get('b', 22))
reveal_type(z.get('b', 'hello'))
```

Before:
```shell
test_get_default.py:2: error: Revealed type is 'builtins.int*'
test_get_default.py:3: error: Revealed type is 'builtins.int*'
test_get_default.py:4: error: Revealed type is 'builtins.int*'
test_get_default.py:4: error: Argument 2 to "get" of "dict" has incompatible type "str"; expected "int"
```

After:
```shell
test_get_default.py:2: error: Revealed type is 'Union[builtins.int*, builtins.None]'
test_get_default.py:3: error: Revealed type is 'builtins.int'
test_get_default.py:4: error: Revealed type is 'Union[builtins.int, builtins.str*]'
```
2017-01-11 22:02:29 -08:00
Jelle Zijlstra
f9135c5aa0 add __init_subclass__ to 3.6 (#813)
See also https://github.com/python/mypy/pull/2654
2017-01-09 09:22:20 -08:00
David Fisher
2cb8e184cc Add NoReturn (#811)
* Add NoReturn
2017-01-04 13:38:05 -08:00
z33ky
93bb4604cb Add special methods for object (#774)
* Add special methods for object

* Add __format__ to 2/__builtin__.pyi too

* Remove redundant __format__ from float.
2017-01-04 13:52:51 +00:00
Lukasz Langa
6e2709906b Fixing flake8 B errors 2016-12-20 01:17:38 -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
TrueBrain
7e89fc0d49 Define __slots__ for object as Iterable[str] / Iterable[Union[str, unicode]] (#780)
* Define __slots__ for object as Iterable[str] / Iterable[Union[str, unicode]]
* A string as __slots__ value is also valid and represents a single item
2016-12-19 13:09:04 -08:00
David Fisher
beb9183103 Swap order of overloads to fix filter without strict optional (#779)
Related to python/mypy#2587
2016-12-16 15:57:04 -08:00
David Fisher
957307b785 Make filter work properly with Optional elements (#775) 2016-12-15 17:53:38 -08:00
Jelle Zijlstra
97a6d27558 Make first argument to filter optional
```
$ python3.4
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> list(filter(None, [False, True]))
[True]
>>> 
```
2016-12-12 11:31:12 -08:00
Josiah Boning
c9ad4b8dc0 Have frozenset inherit from FrozenSet (#726)
Fixes python/mypy#2514
2016-11-30 17:58:11 -08:00
TrueBrain
341c4edc37 Args is a predefined attribute on BaseException, and always Tuple[Any, ...] (#666) 2016-11-05 16:33:58 -07:00
Guido van Rossum
7c20adb715 Fix memoryview stub (#651)
Fixes python/mypy#2390
2016-11-02 17:18:44 -07:00
TrueBrain
15ec66cdd6 Consider __doc__ always Optional. (#641)
python/mypy#2380 showed a discrepancy between object and FunctionType in stdlib2. The first defined __doc__ to be str, the second Optional[str]. As FunctionType depends on object, this is no longer valid.

As suggested by @gvanrossum in python/mypy#2380, all __doc__ should be considered Optional.

(Final verdict was just to remove most __doc__ attributes since it's inherited from object.)
2016-10-30 11:48:23 -07:00
Elazar Gershuni
7a623f2cea Dedicated TypeVar for type.__subclasses__ (#639) 2016-10-30 10:29:51 -07:00