diff --git a/src/sphinxcontrib/towncrier/_fragment_discovery.py b/src/sphinxcontrib/towncrier/_fragment_discovery.py index 4903366..8ad506e 100644 --- a/src/sphinxcontrib/towncrier/_fragment_discovery.py +++ b/src/sphinxcontrib/towncrier/_fragment_discovery.py @@ -68,17 +68,34 @@ def lookup_towncrier_fragments( # noqa: WPS210 fragment_directory: Optional[str] = 'newsfragments' try: - fragment_base_directory = project_path / towncrier_config['directory'] + try: + # Towncrier < 24.7.0rc1 + fragment_base_directory = project_path / towncrier_config['directory'] + except TypeError: + # Towncrier >= 24.7.0rc1 + fragment_base_directory = project_path / towncrier_config.directory + if fragment_base_directory is None: + raise KeyError except KeyError: assert fragment_directory is not None fragment_base_directory = project_path / fragment_directory 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 + _fragments, fragment_filenames = find_fragments( + str(fragment_base_directory), + towncrier_config['sections'], + fragment_directory, + towncrier_config['types'], + ) + except TypeError: + # Towncrier >= 24.7.0rc1 + _fragments, fragment_filenames = find_fragments( + str(fragment_base_directory), + towncrier_config, + strict=False, + ) + return set(fragment_filenames)