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 22, 2024
1 parent e032be3 commit abd6647
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:

Check warning on line 71 in src/sphinxcontrib/towncrier/_fragment_discovery.py

View check run for this annotation

Codecov / codecov/patch

src/sphinxcontrib/towncrier/_fragment_discovery.py#L71

Added line #L71 was not covered by tests
# Towncrier < 24.7.0rc1
fragment_base_directory = project_path / towncrier_config['directory']
except TypeError:

Check warning on line 74 in src/sphinxcontrib/towncrier/_fragment_discovery.py

View check run for this annotation

Codecov / codecov/patch

src/sphinxcontrib/towncrier/_fragment_discovery.py#L73-L74

Added lines #L73 - L74 were not covered by tests
# Towncrier >= 24.7.0rc1
fragment_base_directory = project_path / towncrier_config.directory

Check warning on line 76 in src/sphinxcontrib/towncrier/_fragment_discovery.py

View check run for this annotation

Codecov / codecov/patch

src/sphinxcontrib/towncrier/_fragment_discovery.py#L76

Added line #L76 was not covered by tests
if fragment_base_directory is None:
raise KeyError

Check warning on line 78 in src/sphinxcontrib/towncrier/_fragment_discovery.py

View check run for this annotation

Codecov / codecov/patch

src/sphinxcontrib/towncrier/_fragment_discovery.py#L78

Added line #L78 was not covered by tests
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:

Check warning on line 85 in src/sphinxcontrib/towncrier/_fragment_discovery.py

View check run for this annotation

Codecov / codecov/patch

src/sphinxcontrib/towncrier/_fragment_discovery.py#L85

Added line #L85 was not covered by tests
# Towncrier < 24.7.0rc1
_fragments, fragment_filenames = find_fragments(

Check warning on line 87 in src/sphinxcontrib/towncrier/_fragment_discovery.py

View check run for this annotation

Codecov / codecov/patch

src/sphinxcontrib/towncrier/_fragment_discovery.py#L87

Added line #L87 was not covered by tests
str(fragment_base_directory),
towncrier_config['sections'],
fragment_directory,
towncrier_config['types'],
)
except TypeError:

Check warning on line 93 in src/sphinxcontrib/towncrier/_fragment_discovery.py

View check run for this annotation

Codecov / codecov/patch

src/sphinxcontrib/towncrier/_fragment_discovery.py#L93

Added line #L93 was not covered by tests
# Towncrier >= 24.7.0rc1
_fragments, fragment_filenames = find_fragments(

Check warning on line 95 in src/sphinxcontrib/towncrier/_fragment_discovery.py

View check run for this annotation

Codecov / codecov/patch

src/sphinxcontrib/towncrier/_fragment_discovery.py#L95

Added line #L95 was not covered by tests
str(fragment_base_directory),
towncrier_config,
strict=False,
)

return set(fragment_filenames)

0 comments on commit abd6647

Please sign in to comment.