* 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.
The concurrent.futures.Future class's set_exception() method might be
called with a BaseException that is not an Exception, so change
set_exception()'s parameter type from Exception to BaseException. The
exception set via set_exception() is returned by exception(), so
change exception()'s return type from Exception to BaseException.
A previous PR led mypy to refuse to instantiate ChainMap,
because it had unimplemented abstract methods.
This PR adds the abstract methods to the stub,
which is enough to persuade mypy to allow instantiating
ChainMap.
As of Python 3.3, copymode, copystat, copy and copy2 take an
optional argument, 'follow_symlinks'.
As of Python 3.3, copytree and move return the destination.
As of Python 3.5, move takes an optional copy function.
As of Python 3.3, disk_usage, chown, which and get_terminal_size
were added.
* Added object.__sizeof__
* Removed __sizeof__ inherited from object
* Made sqlite3 classes for Python 2 inherit from object
* Removed __sizeof__ inherited from object
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
This type is something core to Python and is useful when typing web applications,
but doesn't actually exist in the stdlib anywhere. I put this in wsgiref, but I am
open to suggestions as for a better place.
(Original PR by @rowillia.)
**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]'
```
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*]'
```