Skip to content

Commit 11aa657

Browse files
authored
Merge pull request #33 from slsh1o/mypy_pre-commit
Add `mypy` hook to pre-commit
2 parents 26fdbad + cdefe50 commit 11aa657

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ repos:
7272
- flake8-pytest-style>=1.0.0
7373
- wemake-python-styleguide
7474

75+
- repo: https://github.com/pre-commit/mirrors-mypy
76+
rev: v0.782
77+
hooks:
78+
- id: mypy
79+
# empty args needed in order to match mypy cli behavior
80+
args: []
81+
additional_dependencies:
82+
- Sphinx>=3.1.2
83+
7584
- repo: local
7685
hooks:
7786
- id: pylint

mypy.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[mypy]
2+
python_version = 3.6
3+
color_output = True
4+
error_summary = True
5+
6+
check_untyped_defs = True
7+
8+
disallow_untyped_calls = True
9+
disallow_any_generics = True
10+
11+
follow_imports = normal
12+
13+
ignore_missing_imports = False
14+
15+
strict_optional = True
16+
17+
warn_redundant_casts = True
18+
warn_unused_ignores = True

src/sphinxcontrib/towncrier/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import sys
66
from functools import lru_cache
77
from pathlib import Path
8-
from typing import Any, Dict, List, Union
8+
from typing import Dict, List, Tuple, Union
99

1010
from sphinx.application import Sphinx
11+
from sphinx.config import Config as SphinxConfig
1112
from sphinx.util.docutils import SphinxDirective
1213
from sphinx.util.nodes import nested_parse_with_titles, nodes
1314

@@ -35,7 +36,7 @@ def _get_changelog_draft_entries(
3536
config_path: str = None,
3637
) -> str:
3738
"""Retrieve the unreleased changelog entries from Towncrier."""
38-
extra_cli_args = (
39+
extra_cli_args: Tuple[str, ...] = (
3940
'--version',
4041
rf'\ {target_version}', # version value to be used in the RST title
4142
# NOTE: The escaped space sequence (`\ `) is necessary to address
@@ -66,7 +67,10 @@ def _get_changelog_draft_entries(
6667

6768

6869
@lru_cache(maxsize=1, typed=True)
69-
def _get_draft_version_fallback(strategy: str, sphinx_config: Dict[str, Any]):
70+
def _get_draft_version_fallback(
71+
strategy: str,
72+
sphinx_config: SphinxConfig,
73+
) -> str:
7074
"""Generate a fallback version string for towncrier draft."""
7175
known_strategies = {'draft', 'sphinx-version', 'sphinx-release'}
7276
if strategy not in known_strategies:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This stub file is necessary because `_scm_version.py`
2+
# autogenerated on build and absent on mypy checks time
3+
version: str

0 commit comments

Comments
 (0)