python-jose icon indicating copy to clipboard operation
python-jose copied to clipboard

🛠 Added typings for public api (and mypy checks)

Open k4black opened this issue 4 years ago • 3 comments

Typings for all publicly available functions have been added. upd: missed it: Related to #215

Motivation

When integrating python-jose into the fastapi (PR #3305) library, there were additional difficulties due to the lack of type annotation in this library.

Changes

Changes were made only in the typings and did not affect the 'logic'. One exception:

  • Switching from Mapping to dict when checking the payload type.
    For a full discussion, see a similar question in PyJWT lib (Issue #392).

And small fixes in confusing examples and removed typings in docstrings (bytes instead of str, etc)

upd: added py.typed file according to PEP-561

Full typings 😳

I was there, Gandalf. I was there 3000 years ago...

It's really hard. Really. You can check out the typings branch in my fork repository.
But it's worth doing

  1. a lot of errors in the annotation in the comments to the function
  2. lots of confusing names and re-uses typed variables in the backends code
  3. Augean Stables (typing-version) in the file cryptography_backend.py

k4black avatar Jun 08 '21 18:06 k4black

Codecov Report

Merging #265 (3496708) into master (cfbb868) will increase coverage by 0.08%. The diff coverage is 98.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #265      +/-   ##
==========================================
+ Coverage   92.94%   93.03%   +0.08%     
==========================================
  Files          15       15              
  Lines        1418     1450      +32     
==========================================
+ Hits         1318     1349      +31     
- Misses        100      101       +1     
Impacted Files Coverage Δ
jose/jws.py 94.48% <94.11%> (-0.56%) :arrow_down:
jose/backends/__init__.py 100.00% <100.00%> (ø)
jose/constants.py 100.00% <100.00%> (ø)
jose/jwe.py 81.15% <100.00%> (ø)
jose/jwk.py 82.45% <100.00%> (+0.31%) :arrow_up:
jose/jwt.py 98.27% <100.00%> (+0.26%) :arrow_up:
jose/utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cfbb868...3496708. Read the comment docs.

codecov[bot] avatar Jul 04 '21 22:07 codecov[bot]

Please, see this PR - I moved pytest.ini config to pyproject.toml.
Maybe this will come in handy

k4black avatar Jul 06 '21 13:07 k4black

@mpdavis or @blag, can you review this PR, please?
Is it relevant?

k4black avatar Dec 07 '21 21:12 k4black