Skip to content

Commit

Permalink
🚑 Implement compatibility with Towncrier 24.7+
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Dec 21, 2024
1 parent dcc063f commit 87c2e8e
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/sphinxcontrib/towncrier/_fragment_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 87c2e8e

Please sign in to comment.