According to the documentation in the typing module, TypeVars cannot
have only a single constraint. Attempting to do so will actually result
in an exception at runtime. (However, this error is currently ignored
by mypy -- see https://github.com/python/mypy/pull/2626 for a related
pending pull request).
This commit changes all instances of TypeVars using a single constraint
(e.g. `T = TypeVar('T', Foo)`) to use bounds instead (e.g.
`T = TypeVar('T', bound=Foo)`.
This seems to be the correct fix for plistlib after reading the module
docs, but it's less obvious this is correct for unittest. The unittest
module originally had `_FT = TypeVar('_FT', Callable[[Any], Any])` -- an
alternative fix would have been to do `_FT = Callable[[Any], Any]`.
Although I'm not entirely sure what it means to have a bound be a
Callable, I decided to make the assumption that the original authors
probably meant to use TypeVars instead of type aliases for a reason
(possibly to handle classes implementing `__call__`?)
* Add support for request.get's 'params' param
Requests defines the following API:
`get(url, params=None, **kwargs)`
* Improve typing for requests.get(params)
Add support for string form, and tighten restrictions for the dict form
to allow only string keys/vals. Technically, anything is allowed since
the code (I guess) runs `str(key)` and `str(value)`, but it seems better
to keep the stub somewhat strict so it can help pick up potential
errors.
Improve operator methods for dateutil.relativedelta stubs:
* `__add__` operator method could return other types than `relativedelta` (`datetime.date` or `datetime.datetime`)
* use specific types of operators args instead of Any
* mypy currently does not handle `Union` in op methods (see python/mypy#2129, python/mypy#1442, python/mypy#1264 for details), so I've overloaded it directly
Starting with python/mypy#2521 mypy is performing stricter function signature
checks.
This makes the stubs diverge from the actual implementation but makes the stubs
internally consistent. Since this is an actual typing issue in the base
implementation, we need to defer to the original authors to fix it.
Sadly, in this case the breakage is rather fundamental and unlikely to get
fixed by upstream. Consider:
```
class AWSAuthConnection(object):
def make_request(self, method, path, headers=None, data='', host=None,
auth_path=None, sender=None, override_num_retries=None,
params=None, retry_handler=None): ...
class AWSQueryConnection(AWSAuthConnection):
def make_request(self, action, params=None, path='/', verb='GET'): ...
```
Hence, until we have a workaround for the error produced by Mypy, we're
excluding those stubs from being tested against.
Starting with python/mypy#2521 mypy is performing stricter function signature
checks.
This makes the stubs diverge from the actual implementation but makes the stubs
internally consistent. Since this is an actual typing issue in the base
implementation, we need to defer to the original authors to fix it.
Starting with python/mypy#2521 mypy is performing stricter function signature
checks.
This makes the stubs diverge from the actual implementation but makes the stubs
internally consistent. Since this is an actual typing issue in the base
implementation, we need to defer to the original authors to fix it.
Starting with python/mypy#2521 mypy is performing stricter function signature
checks.
This makes the stubs diverge from the actual implementation but makes the stubs
internally consistent. Since this is an actual typing issue in the base
implementation, we need to defer to the original authors to fix it.
This simplifies running flake8 tests and reduces the amount of F821 errors
reported (flake8-pyi enables support for forward references in *.pyi files).
The error code is left disabled until I clean up the remaining issues.
Ran both by Travis and locally. There's some setup required, README updated.
A few important Flake8 checks are still disabled, we're going to enable them as
soon as the stubs are fixed and we can reliably run Flake8 locally with Python
3.6.