From 3f430a971a3a5eac8eb954a269b49a5343d9aeb4 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Sat, 31 Aug 2024 04:20:42 +0200 Subject: [PATCH] Make the project compatible with Towncrier >= 24.7 Towncrier 24.7 changed the way that its `find_fragments()` function works to accept a `Config` dataclass instead of specific components of the config. Co-Authored-By: Ben Rowland Closes #94 Resolves #92 --- .../towncrier/_fragment_discovery.py | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/sphinxcontrib/towncrier/_fragment_discovery.py b/src/sphinxcontrib/towncrier/_fragment_discovery.py index cf5d605..b98e2c0 100644 --- a/src/sphinxcontrib/towncrier/_fragment_discovery.py +++ b/src/sphinxcontrib/towncrier/_fragment_discovery.py @@ -67,10 +67,26 @@ def lookup_towncrier_fragments( # noqa: WPS210 else: fragment_directory = None - _fragments, fragment_filenames = find_fragments( - str(fragment_base_directory), - towncrier_config.sections, - fragment_directory, - towncrier_config.types, - ) + try: + # Towncrier < 24.7.0rc1 + # pylint: disable-next=no-value-for-parameter + # pylint: disable-next=too-many-function-args + # pylint: disable-next=unexpected-keyword-arg + _fragments, fragment_filenames = find_fragments( + base_directory=str(fragment_base_directory), + sections=towncrier_config.sections, + fragment_directory=fragment_directory, + frag_type_names=towncrier_config.types, + orphan_prefix='+', + ) + except TypeError: + # Towncrier >= 24.7.0rc1 + _fragments, fragment_filenames = find_fragments( # noqa: WPS121 + base_directory=str(fragment_base_directory), + config=towncrier_config, + strict=False, + ) + + return {Path(fname[0]) for fname in fragment_filenames} + return set(fragment_filenames)