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

Add type hints in the public API

Open texasaggie97-zz opened this issue 4 years ago • 1 comments

  • [X] This contribution adheres to CONTRIBUTING.md.
  • [X] I've updated CHANGELOG.md if applicable.
  • [ ] I've added tests applicable for this pull request

What does this Pull Request accomplish?

  • Add type hints to public API
    • Uses type_in_documentation metadata since it mostly has the information needed - we need the complete list of possible types in the API, not just the type that is passed into the DLL
    • Several special cases to deal with free form test
    • Not sure how to put this information into the metadata
  • Most type hints are calculated
  • A few in fancy functions are hardcoded
  • The preferred method for type hinting namedtuples is to create a class that inherits from typing.NamedTuple. This would require the couple of namedtuples we have to be moved to custom types. I did not do that work for this PR.

~~List issues fixed by this Pull Request below, if any.~~

What testing has been done?

  • Unit tests and flake8 still pass with type hinting added
  • Need to add mypy tests, maybe using examples?

texasaggie97-zz avatar Nov 10 '20 15:11 texasaggie97-zz

Codecov Report

Merging #1530 (28c9e39) into master (be1d5aa) will decrease coverage by 0.33%. The diff coverage is 87.32%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1530      +/-   ##
==========================================
- Coverage   91.66%   91.33%   -0.34%     
==========================================
  Files          20       20              
  Lines        3457     3510      +53     
==========================================
+ Hits         3169     3206      +37     
- Misses        288      304      +16     
Flag Coverage Δ
codegenunittests 87.75% <64.70%> (-0.52%) :arrow_down:
nifakeunittests 96.35% <100.00%> (+<0.01%) :arrow_up:
nimodinstunittests 95.40% <100.00%> (+0.02%) :arrow_up:
nitclkunittests 95.65% <100.00%> (+0.03%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
build/helper/codegen_helper.py 90.22% <7.69%> (-2.30%) :arrow_down:
build/helper/metadata_add_all.py 81.85% <83.78%> (+0.50%) :arrow_up:
build/helper/__init__.py 100.00% <100.00%> (ø)
generated/nifake/nifake/session.py 97.71% <100.00%> (+<0.01%) :arrow_up:
generated/nimodinst/nimodinst/session.py 95.40% <100.00%> (+0.02%) :arrow_up:
generated/nitclk/nitclk/session.py 95.65% <100.00%> (+0.03%) :arrow_up:

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 be1d5aa...28c9e39. Read the comment docs.

codecov[bot] avatar Nov 10 '20 18:11 codecov[bot]