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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PEP-484 type annotations #23

Closed
wants to merge 10 commits into from

Conversation

dave-shawley
Copy link
Contributor

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:

image

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:

image

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 馃槥

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
Copy link

codecov bot commented Feb 7, 2020

Codecov Report

Merging #23 into master will increase coverage by 4.81%.
The diff coverage is 100%.

Impacted file tree graph

@@           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
Impacted Files Coverage 螖
sprockets/mixins/mediatype/transcoders.py 100% <100%> (+10.16%) 猬嗭笍
sprockets/mixins/mediatype/type_info.py 100% <100%> (酶)
sprockets/mixins/mediatype/content.py 100% <100%> (+3%) 猬嗭笍
sprockets/mixins/mediatype/__init__.py 100% <100%> (酶) 猬嗭笍
sprockets/mixins/mediatype/handlers.py 100% <100%> (酶) 猬嗭笍

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 e40449b...d471bd2. Read the comment docs.

@dave-shawley
Copy link
Contributor Author

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.

@dave-shawley dave-shawley mentioned this pull request Sep 16, 2021
@dave-shawley dave-shawley deleted the typing branch September 19, 2021 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant