pyca / pynacl

Python binding to the Networking and Cryptography (NaCl) library
https://pynacl.readthedocs.io/
Apache License 2.0
1.05k stars 231 forks source link

Mypy tests 3 #730

Closed DMRobertson closed 2 years ago

DMRobertson commented 2 years ago

Also a draft. Branches off from #728; the first new commit is 8cfeced. I'm just sticking this up to get CI to run on the proposed final batch of annotations to tests now.

Also, while I'm at it, I wanted to see if we could quantify how much has changed with all this typing. To do so:

git checkout mypy-tests-3
mypy --html-report out --any-exprs-report out
xdg-open out/index.html
less out/any-exprs.txt

git checkout ee93f9f13e4ce803a707b972d0fbc324439e71fc
git restore --source=mypy-tests-3 pyproject.toml
mypy --html-report out_old --any-exprs-report out_old
xdg-open out_old/index.html
less out_old/any-exprs.txt

TL:DR:

(These numbers from the any-exprs and html reports, respectively).

I think most of that comes down to cffi in nacl; maybe some bits in tests from json.loads().

If we just look at the higher level stuff outside of nacl.bindings, the numbers are rosier:

$ less out/any-exprs.txt | \grep nacl | \grep -v bindings 
                             nacl      0      19    100.00%
                    nacl.encoding      0      70    100.00%
                  nacl.exceptions      0      27    100.00%
                        nacl.hash      0     105    100.00%
                     nacl.hashlib      0     137    100.00%
                      nacl.public      5     489     98.98%
                      nacl.pwhash      0      85    100.00%
              nacl.pwhash._argon2      0      31    100.00%
              nacl.pwhash.argon2i      0      71    100.00%
             nacl.pwhash.argon2id      0      71    100.00%
               nacl.pwhash.scrypt      1     129     99.22%
                      nacl.secret      2     276     99.28%
                     nacl.signing      6     278     97.84%
                       nacl.utils      0      59    100.00%
DMRobertson commented 2 years ago

Codecov complains, but AFAICS there's no complaint here: https://app.codecov.io/gh/pyca/pynacl/compare/730?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=checks&utm_campaign=pr%20comments&utm_term=pyca

reaperhulk commented 2 years ago

I'm going to avoid further nitpicking here since we can always find ways to improve in the future. 😁

DMRobertson commented 2 years ago

For what it's worth, I'm open to nitpicking. Either way, great to see this merged and rounded off!