Skip to content

Annotate jwt.algorithms - #2532

Merged
JelleZijlstra merged 4 commits into
python:masterfrom
srittau:jwt
Oct 23, 2018
Merged

JelleZijlstra merged 4 commits into
python:masterfrom
srittau:jwt

Conversation

@srittau

@srittau srittau commented Oct 21, 2018

Copy link
Copy Markdown
Collaborator

Cf. #1446

Comment thread third_party/3/jwt/algorithms.pyi Outdated
@staticmethod
def to_jwk(key_obj: _K) -> str: ...
@staticmethod
def from_jwk(jwk: str) -> _K: ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this works correctly:

$ cat bin/genstat.py 
from typing import *

T = TypeVar('T')

class A(Generic[T]):
    @staticmethod
    def foo() -> T:
        pass

class B(A[int]):
    pass

reveal_type(B.foo())
$ python3.7 -m mypy bin/genstat.py 
bin/genstat.py:13: error: Revealed type is 'T`1'

This is python/mypy#1337.

There doesn't appear to be a good workaround, so we may have to use Any for now.

Comment thread third_party/3/jwt/algorithms.pyi Outdated
SHA256: ClassVar[_HashAlg]
SHA384: ClassVar[_HashAlg]
SHA512: ClassVar[_HashAlg]
has_alg: _HashAlg

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash_alg

Comment thread third_party/3/jwt/algorithms.pyi Outdated
def __init__(self, _HashAlg) -> None: ...
def prepare_key(self, key: Union[str, bytes]) -> bytes: ...
@staticmethod
def to_jwk(key_obj: Union[str, bytes]) -> Any: ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to actually return str.

Comment thread third_party/3/jwt/algorithms.pyi Outdated
@staticmethod
def from_jwk(jwk: _LoadsString) -> bytes: ...

# If cryptography is installed, also has classes RSAAlgorithm and ECAlgorithm.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also have stubs for these classes then. False negatives are better than false positives.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I left them out for now, since we don't have stubs for cryptography, yet, but we could of course use Any.

@JelleZijlstra
JelleZijlstra merged commit c4f4c40 into python:master Oct 23, 2018
@srittau
srittau deleted the jwt branch October 23, 2018 16:45
yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants