sphinx-contrib / sphinxcontrib-towncrier

An RST directive for injecting a Towncrier-generated changelog draft containing fragments for the unreleased (next) project version. Demo: https://ansible-pylibssh.rtfd.io/changelog. Docs: https://sphinxcontrib-towncrier.rtfd.io
https://pypi.org/p/sphinxcontrib-towncrier
BSD 3-Clause "New" or "Revised" License
19 stars 18 forks source link

Add `mypy` hook to pre-commit #33

Closed slsh1o closed 4 years ago

slsh1o commented 4 years ago

I'm not sure what else should I add to mypy.ini. Something related to tests or maybe to sphinx.

And also there are some errors which idk how to fix better.

Ref: #16

slsh1o commented 4 years ago

Slightly reorder mypy.ini but I'm still not sure how to cure raised errors.

webknjaz commented 4 years ago

but I'm still not sure how to cure raised errors

First, try exploring what causes these errors. Then, we'll decide how to deal with each of them.

webknjaz commented 4 years ago
src/sphinxcontrib/towncrier/_version.py:5: error: Cannot find implementation or library stub for module named 'towncrier._scm_version'
src/sphinxcontrib/towncrier/_version.py:5: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports

Try creating a stub file for _scm_version: https://mypy.readthedocs.io/en/stable/stubs.html.

webknjaz commented 4 years ago
src/sphinxcontrib/towncrier/__init__.py:55: error: Incompatible types in assignment (expression has type "Tuple[str, str, str, str]", variable has type "Tuple[str, str]")

I guess mypy "sees" the initial declaration that is Tuple[str, str] and automatically decides that it's the final type. You should probably mark it as something like iterable explicitly.

webknjaz commented 4 years ago
src/sphinxcontrib/towncrier/__init__.py:80: error: "Dict[str, Any]" has no attribute "release"
src/sphinxcontrib/towncrier/__init__.py:82: error: "Dict[str, Any]" has no attribute "version"

This is just an incorrect annotation. It's best to figure out what type it is really. Maybe stick a debugger there...