aiohttp-swagger
aiohttp-swagger copied to clipboard
Add 'py.typed' file
This package uses typehints, however mypy gives the following error when run on packages that import it:
error: Skipping analyzing 'aiohttp_swagger': found module but no type hints or library stubs
The solution is to include a py.typed file that gets included in the main package upon distribution. This is identical as to how aiohttp packages its typehints as well.
Now, if you were to try passing in an incorrect type for ui_version to setup_swagger, for instance, you get information about the error using mypy
error: Argument "ui_version" to "setup_swagger" has incompatible type "str"; expected "Optional[int]"
All unit tests still pass:
(my_venv) omikader@omikader-mbp aiohttp-swagger % python setup.py test
running test
============================================================================================================ test session starts =============================================================================================================
platform darwin -- Python 3.7.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /Users/omikader/GitHub/aiohttp-swagger
plugins: aiohttp-0.3.0
collected 27 items
tests/test_openapi.py ............ [ 44%]
tests/test_swagger.py ............... [100%]
============================================================================================================== warnings summary ==============================================================================================================
tests/test_openapi.py: 12 warnings
tests/test_swagger.py: 15 warnings
/private/tmp/my_venv/lib/python3.7/site-packages/_pytest/fixtures.py:932: DeprecationWarning: Deprecated, use aiohttp_client fixture instead
fixture_result = fixturefunc(**kwargs)
-- Docs: https://docs.pytest.org/en/stable/warnings.html
====================================================================================================== 27 passed, 27 warnings in 1.19s =======================================================================================================
Codecov Report
Merging #96 (d53eac0) into master (ea32115) will not change coverage. The diff coverage is
n/a.
@@ Coverage Diff @@
## master #96 +/- ##
=======================================
Coverage 94.85% 94.85%
=======================================
Files 4 4
Lines 136 136
=======================================
Hits 129 129
Misses 7 7
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update ea32115...d53eac0. Read the comment docs.