Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ repos:
- flake8-pytest-style>=1.0.0
- wemake-python-styleguide

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782
hooks:
- id: mypy
# empty args needed in order to match mypy cli behavior
args: []
additional_dependencies:
- Sphinx>=3.1.2

- repo: local
hooks:
- id: pylint
Expand Down
18 changes: 18 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[mypy]
python_version = 3.6
color_output = True
error_summary = True

check_untyped_defs = True

disallow_untyped_calls = True
disallow_any_generics = True

follow_imports = normal

ignore_missing_imports = False

strict_optional = True

warn_redundant_casts = True
warn_unused_ignores = True
10 changes: 7 additions & 3 deletions src/sphinxcontrib/towncrier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import sys
from functools import lru_cache
from pathlib import Path
from typing import Any, Dict, List, Union
from typing import Dict, List, Tuple, Union

from sphinx.application import Sphinx
from sphinx.config import Config as SphinxConfig
from sphinx.util.docutils import SphinxDirective
from sphinx.util.nodes import nested_parse_with_titles, nodes

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


@lru_cache(maxsize=1, typed=True)
def _get_draft_version_fallback(strategy: str, sphinx_config: Dict[str, Any]):
def _get_draft_version_fallback(
strategy: str,
sphinx_config: SphinxConfig,
) -> str:
"""Generate a fallback version string for towncrier draft."""
known_strategies = {'draft', 'sphinx-version', 'sphinx-release'}
if strategy not in known_strategies:
Expand Down
3 changes: 3 additions & 0 deletions src/sphinxcontrib/towncrier/_scm_version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This stub file is necessary because `_scm_version.py`
# autogenerated on build and absent on mypy checks time
version: str