Skip to content

Commit

Permalink
Adjust config loader import for towncrier>=22.8.0
Browse files Browse the repository at this point in the history
This patch implements compatibility with the newly released
`towncrier >= 22.8.0rc1`. Since the extension relies on the
Towncrier's private API, this sort of thing is bound to happen time to
time. It is solved by using a fallback import logic.

This change also adds the said Towncrier version to the CI matrix.

Fixes
#60.
  • Loading branch information
webknjaz committed Aug 31, 2022
2 parents 31094ea + 9df5445 commit f6e314a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tox-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
strategy:
matrix:
towncrier-version:
- 22.8.0
- 21.9.0rc1
- 21.3.0
- 19.9.0
Expand All @@ -74,6 +75,8 @@ jobs:
exclude:
- os: ubuntu-22.04
python-version: 3.6 # EOL, only provided for older OSs
- python-version: 3.6
towncrier-version: 22.8.0 # Dropped support for Python 3.6

env:
PY_COLORS: 1
Expand Down
14 changes: 12 additions & 2 deletions src/sphinxcontrib/towncrier/_towncrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
from pathlib import Path
from typing import Any, Dict

# pylint: disable=import-error,no-name-in-module
from towncrier._settings import load_config_from_file # noqa: WPS436

try:
# Towncrier >= 22.8.0rc1
# pylint: disable=import-error,no-name-in-module
from towncrier._settings.load import ( # noqa: WPS433, WPS436
load_config_from_file,
)
except ImportError:
# pylint: disable=import-error,no-name-in-module
from towncrier._settings import ( # noqa: WPS433, WPS436, WPS440
load_config_from_file,
)


def get_towncrier_config(
Expand Down

0 comments on commit f6e314a

Please sign in to comment.