typing: make albums_in_dir, sorted_walk and other utils generic over AnyStr#6806
Open
snejus wants to merge 1 commit into
Open
typing: make albums_in_dir, sorted_walk and other utils generic over AnyStr#6806snejus wants to merge 1 commit into
albums_in_dir, sorted_walk and other utils generic over AnyStr#6806snejus wants to merge 1 commit into
Conversation
|
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry. |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Contributor
There was a problem hiding this comment.
Pull request overview
PR make path helper move from “bytes-only brain” toward “AnyStr brain” so code can walk filesystem with str or bytes and keep same type through.
Changes:
- Make
beets.util.hidden.is_hiddenacceptPathLikeand decode/normalize intoPath. - Change
beets.util.sorted_walktyping/output to be generic overAnyStr(str/bytes) and adjust sorting to match path type. - Update importer
albums_in_dirmulti-disc detection so regex + ignore patterns work for bothstrandbytespaths.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| beets/util/hidden.py | Widen hidden-path helper to accept broader path inputs and normalize via Path. |
| beets/util/init.py | Make sorted_walk generic over AnyStr and preserve path type through traversal. |
| beets/importer/tasks.py | Make albums_in_dir and multi-disc regex logic work for str and bytes paths. |
Comment on lines
+204
to
+208
| path: AnyStr, | ||
| ignore: Sequence[AnyStr] = (), | ||
| ignore_hidden: bool = False, | ||
| logger: Logger | None = None, | ||
| ) -> Iterator[tuple[bytes, Sequence[bytes], Sequence[bytes]]]: | ||
| ) -> Iterator[tuple[AnyStr, Sequence[AnyStr], Sequence[AnyStr]]]: |
| ) -> bool: | ||
|
|
||
| def is_subdir_of_any_in_list(path: AnyStr, dirs: list[AnyStr]) -> bool: | ||
| """Returns True if path os a subdirectory of any directory in dirs |
9edd8a2 to
eb3e21e
Compare
f2f5997 to
7716532
Compare
eb3e21e to
47376bf
Compare
7716532 to
9232a66
Compare
47376bf to
010d0a7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change makes the path-handling utilities
is_hidden,sorted_walk,unique_path,remux_mpeglayer3_wavandalbums_in_dirwork with bothstrandbytespaths instead of assumingbyteseverywhere.Architecturally, the PR moves these helpers toward a single generic path flow using
AnyStr, so callers can stay in their native path type while the utilities preserve that type through traversal, filtering, and hidden-file checks.In
albums_in_dir, the multi-disc detection logic was updated to support both string and byte paths by splitting regex handling intostrandbytesvariants while keeping the existing album-collapsing behavior the same.High-level impact: this reduces path-conversion friction, improves typing consistency across importer and util code, and makes the filesystem helpers easier to reuse as the codebase continues moving away from
bytes-only assumptions.