-
Notifications
You must be signed in to change notification settings - Fork 3
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PEP-484 type annotations #23
Conversation
I also updated the travis CI file to require 100% and added a tox target that has "min coverage percent" set to 100%.
There were a lot of broken links and some images broken in the README. Unfortunately, linkcheck still does not run clean because it doesn't seem to be able to parse the msgpack markdown served by github correctly.
Fixed a few docstrings and made some of the tests a little more typesafe.
Sphinx API documentation with type hinting is more complex than it needs to be. This probably would have been a little easier if we went "whole- hog" and created a much more complex inheritance tree. Instead, I chose to represent protocols as type constraints rather than inherited requirements. This is more inline with Python duck typing.
I added the minimal necessary to make the documentation at least readable.
We were using it implicitly by hosting on readthedocs.io so we might as well build local docs that match. I also added a readthedocs.yaml configuration file that makes everything explicit. Hopefully this works as expected #fingerscrossed Ref: https://docs.readthedocs.io/en/stable/config-file/v2.html Ref: https://github.com/readthedocs/readthedocs.org/blob/master/readthedocs/rtd_tests/fixtures/spec/v2/schema.yml Ref: https://github.com/readthedocs/readthedocs.org/pull/6501/files
Codecov Report
@@ Coverage Diff @@
## master #23 +/- ##
========================================
+ Coverage 95.18% 100% +4.81%
========================================
Files 4 5 +1
Lines 187 223 +36
Branches 23 24 +1
========================================
+ Hits 178 223 +45
+ Misses 4 0 -4
+ Partials 5 0 -5
Continue to review full report at Codecov.
|
I'm going to rework this in another MR since a lot has changed since I wrote it both in the codebase and in the typing community. |
This PR adds PEP-484 type annotations and cleans up some documentation. I spent a good bit of time ensuring that the generated documentation doesn't look absolutely horrid. After I added type annotations, the documentation looked like the following:
I went through and cleaned up param strings, documented type aliases explicitly, and generally reworked the docs. I managed to get the documentation into shape (I think). The following is the same documentation after cleanup:
I added a new module that contains documented type aliases that I used in signatures throughout. This made the code fairly readable and type checkers can do a pretty good job of analyzing calls and identifying errors. The serializable & deserialized type definitions are still a little weak since typing cannot represent recursive types correctly 馃槥