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

Incorrect/Misleading type hint for constructors of RecordingSet/SupervisionSet/CutSet #1038

Closed
csukuangfj opened this issue Apr 23, 2023 · 1 comment · Fixed by #1040
Closed

Comments

@csukuangfj
Copy link
Contributor

lhotse/lhotse/audio.py

Lines 960 to 961 in 3c621b5

def __init__(self, recordings: Mapping[str, Recording] = None) -> None:
self.recordings = ifnone(recordings, {})

def __init__(self, segments: Mapping[str, SupervisionSegment]) -> None:
self.segments = ifnone(segments, {})

lhotse/lhotse/cut/set.py

Lines 240 to 241 in 3c621b5

def __init__(self, cuts: Optional[Mapping[str, Cut]] = None) -> None:
self.cuts = ifnone(cuts, {})

But they actually also accept an iterator/Iterable, see the code below:

return cls(LazyManifestIterator(path))

Also, the type hints for RecordingSet/SupervisionSet should use Optional if they accept a None value, like what CutSet is doing.

@csukuangfj
Copy link
Contributor Author

class LazyManifestIterator(ImitatesDict):

I see. LazyManifestIterator acts like a dict. Clever design!

pzelasko added a commit that referenced this issue Apr 24, 2023
pzelasko added a commit that referenced this issue Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant