Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AudioEventsConfig to return empty dict as default #98

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.14.8] - 2024-05-14

### Changed
- AudioEventsConfig class now defaults to empty dict instead of empty list when types not provided

## [1.14.7] - 2024-04-08

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.14.7
1.14.8
4 changes: 2 additions & 2 deletions speechmatics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ class AutoChaptersConfig:

@dataclass
class AudioEventsConfig:
types: Optional[List[str]]
types: Optional[List[str]] = None
"""Optional list of audio event types to detect."""

def asdict(self):
if self.types is None:
self.types = []
return {}
dumitrugutu marked this conversation as resolved.
Show resolved Hide resolved
return asdict(self)


Expand Down
20 changes: 20 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,23 @@ def test_topic_detection_config(params, want):
def test_notification_config(params, want):
notification_config = models.NotificationConfig(**params)
assert asdict(notification_config) == want


@mark.parametrize(
"params, want",
[
param(
{"types": None},
{},
id="default params",
),
param(
{"types": ["music"]},
{"types": ["music"]},
id="set types param",
),
],
)
def test_audio_events_config_config(params, want):
audio_events_config = models.AudioEventsConfig(**params)
assert audio_events_config.asdict() == want
Loading