Fix third_party errors with --disallow-any-generics (#3278)

Part of #3267. Together with #3276 this should fix all such problems.
This commit is contained in:
Sebastian Rittau
2019-09-30 13:14:01 +02:00
committed by Jelle Zijlstra
parent 412b9e74d5
commit ed4b1de0ad
51 changed files with 244 additions and 263 deletions

View File

@@ -3,10 +3,11 @@ import docutils.parsers.rst.states
from typing import Callable, Any, List, Dict, Tuple
def register_local_role(name: str,
role_fn: Callable[[str, str, str, int, docutils.parsers.rst.states.Inliner, Dict, List],
Tuple[List[docutils.nodes.reference], List[docutils.nodes.reference]]]
) -> None:
...
_RoleFn = Callable[
[str, str, str, int, docutils.parsers.rst.states.Inliner, Dict[str, Any], List[str]],
Tuple[List[docutils.nodes.reference], List[docutils.nodes.reference]],
]
def __getattr__(name) -> Any: ...
def register_local_role(name: str, role_fn: _RoleFn) -> None: ...
def __getattr__(name: str) -> Any: ... # incomplete

View File

@@ -11,9 +11,7 @@ def encode(payload: Mapping[str, Any], key: Union[str, bytes],
algorithm: str = ..., headers: Optional[Mapping[str, Any]] = ...,
json_encoder: Optional[Any] = ...) -> bytes: ...
def register_algorithm(alg_id: str,
alg_obj: algorithms.Algorithm) -> None: ...
def register_algorithm(alg_id: str, alg_obj: algorithms.Algorithm[Any]) -> None: ...
def unregister_algorithm(alg_id: str) -> None: ...
class PyJWTError(Exception): ...

View File

@@ -4,7 +4,7 @@ from typing import Any, Set, Dict, Optional, ClassVar, Union, Generic, TypeVar
requires_cryptography = Set[str]
def get_default_algorithms() -> Dict[str, Algorithm]: ...
def get_default_algorithms() -> Dict[str, Algorithm[Any]]: ...
_K = TypeVar("_K")
@@ -13,10 +13,9 @@ class Algorithm(Generic[_K]):
def sign(self, msg: bytes, key: _K) -> bytes: ...
def verify(self, msg: bytes, key: _K, sig: bytes) -> bool: ...
@staticmethod
def to_jwk(key_obj: Any) -> str: ... # should be key_obj: _K, see python/mypy#1337
def to_jwk(key_obj: _K) -> str: ...
@staticmethod
def from_jwk(jwk: str) -> Any: ... # should return _K, see python/mypy#1337
def from_jwk(jwk: str) -> _K: ...
class NoneAlgorithm(Algorithm[None]):
def prepare_key(self, key: Optional[str]) -> None: ...
@@ -44,7 +43,7 @@ class HMACAlgorithm(Algorithm[bytes]):
# Only defined if cryptography is installed. Types should be tightened when
# cryptography gets type hints.
# See https://github.com/python/typeshed/issues/2542
class RSAAlgorithm(Algorithm):
class RSAAlgorithm(Algorithm[Any]):
SHA256: ClassVar[Any]
SHA384: ClassVar[Any]
SHA512: ClassVar[Any]
@@ -61,7 +60,7 @@ class RSAAlgorithm(Algorithm):
# Only defined if cryptography is installed. Types should be tightened when
# cryptography gets type hints.
# See https://github.com/python/typeshed/issues/2542
class ECAlgorithm(Algorithm):
class ECAlgorithm(Algorithm[Any]):
SHA256: ClassVar[Any]
SHA384: ClassVar[Any]
SHA512: ClassVar[Any]

View File

@@ -3,7 +3,7 @@ from jwt.algorithms import Algorithm
from . import _HashAlg
class ECAlgorithm(Algorithm):
class ECAlgorithm(Algorithm[Any]):
SHA256: _HashAlg
SHA384: _HashAlg
SHA512: _HashAlg

View File

@@ -3,7 +3,7 @@ from jwt.algorithms import Algorithm
from . import _HashAlg
class RSAAlgorithm(Algorithm):
class RSAAlgorithm(Algorithm[Any]):
SHA256: _HashAlg
SHA384: _HashAlg
SHA512: _HashAlg