The Wayback Machine - https://web.archive.org/web/20201010214625/https://github.com/jpadilla/pyjwt/issues/312
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python type hints #312

Open
mark-adams opened this issue Nov 27, 2017 · 6 comments
Open

Python type hints #312

mark-adams opened this issue Nov 27, 2017 · 6 comments

Comments

@mark-adams
Copy link
Contributor

@mark-adams mark-adams commented Nov 27, 2017

PEP 484 and PEP 526 introduced the concept of "type hints" which allow Python code to have inline type declarations to make it easier for editors and static analysis tools to work with Python code.

def add(a: int, b: int) -> int:
    return a + b

To maintain Python 2.7 compatibility, we'd have to use the comment-based syntax:

def add(a, b):
    # type: (int, int) -> int
    return a + b

Is this something that might be worthwhile for us to implement?

@jpadilla
Copy link
Owner

@jpadilla jpadilla commented Nov 29, 2017

I'm all up for this. Is there any way to add tests for something like this?

@dmwyatt
Copy link

@dmwyatt dmwyatt commented Dec 4, 2017

You can run mypy against the code and it will tell you if your types don't make sense.

@jacopofar
Copy link
Contributor

@jacopofar jacopofar commented Apr 6, 2018

I'm happy to give it a try, and hopefully include mypy to travis config

@jacopofar
Copy link
Contributor

@jacopofar jacopofar commented Apr 6, 2018

Opend PR #344

@aklim007
Copy link

@aklim007 aklim007 commented May 28, 2018

@jacopofar hello, in decode methods jwt and jws parameters may be bytes, not only str.

@jacopofar
Copy link
Contributor

@jacopofar jacopofar commented May 29, 2018

I see, the library supports Python 2 as well and so the parameter type has to be more flexible. Considering also the problem of the argument changing name, I think the added value of type hinting in this case is not worth it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.