🛠Added typings for public api (and mypy checks)
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
Mappingtodictwhen checking the payload type.
For a full discussion, see a similar question inPyJWTlib (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
- a lot of errors in the annotation in the comments to the function
- lots of confusing names and re-uses typed variables in the backends code
- Augean Stables (typing-version) in the file cryptography_backend.py
Codecov Report
Merging #265 (3496708) into master (cfbb868) will increase coverage by
0.08%. The diff coverage is98.73%.
@@ 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 dataPowered by Codecov. Last update cfbb868...3496708. Read the comment docs.
Please, see this PR - I moved pytest.ini config to pyproject.toml.
Maybe this will come in handy
@mpdavis or @blag, can you review this PR, please?
Is it relevant?