diff --git a/beets/util/__init__.py b/beets/util/__init__.py index e13b67604..411202075 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -210,7 +210,9 @@ def sorted_walk( """ # Make sure the paths aren't Unicode strings. bytes_path = bytestring_path(path) - ignore = [bytestring_path(i) for i in ignore] + _ignore = [ # rename prevents mypy variable shadowing issue + bytestring_path(i) for i in ignore + ] # Get all the directories and files at this level. try: @@ -230,7 +232,7 @@ def sorted_walk( # Skip ignored filenames. skip = False - for pat in ignore: + for pat in _ignore: if fnmatch.fnmatch(base, pat): if logger: logger.debug( @@ -257,7 +259,7 @@ def sorted_walk( # Recurse into directories. for base in dirs: cur = os.path.join(bytes_path, base) - yield from sorted_walk(cur, ignore, ignore_hidden, logger) + yield from sorted_walk(cur, _ignore, ignore_hidden, logger) def path_as_posix(path: bytes) -> bytes: