Skip to content

Commit ea77172

Browse files
committed
pyupgrade Python 3.10
1 parent 9fbf64e commit ea77172

32 files changed

+91
-72
lines changed

beets/autotag/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import warnings
2020
from importlib import import_module
21-
from typing import TYPE_CHECKING, Union
21+
from typing import TYPE_CHECKING
2222

2323
from beets import config, logging
2424

@@ -117,8 +117,8 @@ def __getattr__(name: str):
117117

118118

119119
def _apply_metadata(
120-
info: Union[AlbumInfo, TrackInfo],
121-
db_obj: Union[Album, Item],
120+
info: AlbumInfo | TrackInfo,
121+
db_obj: Album | Item,
122122
nullable_fields: Sequence[str] = [],
123123
):
124124
"""Set the db_obj's metadata to match the info."""

beets/dbcore/db.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@
2626
import time
2727
from abc import ABC
2828
from collections import defaultdict
29-
from collections.abc import Generator, Iterable, Iterator, Mapping, Sequence
29+
from collections.abc import (
30+
Callable,
31+
Generator,
32+
Iterable,
33+
Iterator,
34+
Mapping,
35+
Sequence,
36+
)
3037
from sqlite3 import Connection, sqlite_version_info
31-
from typing import TYPE_CHECKING, Any, AnyStr, Callable, Generic
38+
from typing import TYPE_CHECKING, Any, AnyStr, Generic
3239

3340
from typing_extensions import TypeVar # default value support
3441
from unidecode import unidecode

beets/importer/session.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import os
1717
import time
18-
from typing import TYPE_CHECKING, Sequence
18+
from typing import TYPE_CHECKING
1919

2020
from beets import config, dbcore, library, logging, plugins, util
2121
from beets.importer.tasks import Action
@@ -25,6 +25,8 @@
2525
from .state import ImportState
2626

2727
if TYPE_CHECKING:
28+
from collections.abc import Sequence
29+
2830
from beets.util import PathBytes
2931

3032
from .tasks import ImportTask

beets/importer/stages.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import itertools
1818
import logging
19-
from typing import TYPE_CHECKING, Callable
19+
from typing import TYPE_CHECKING
2020

2121
from beets import config, plugins
2222
from beets.util import MoveOperation, displayable_path, pipeline
@@ -30,6 +30,8 @@
3030
)
3131

3232
if TYPE_CHECKING:
33+
from collections.abc import Callable
34+
3335
from beets import library
3436

3537
from .session import ImportSession

beets/importer/tasks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
import shutil
2121
import time
2222
from collections import defaultdict
23+
from collections.abc import Callable, Iterable, Sequence
2324
from enum import Enum
2425
from tempfile import mkdtemp
25-
from typing import TYPE_CHECKING, Any, Callable, Iterable, Sequence
26+
from typing import TYPE_CHECKING, Any
2627

2728
import mediafile
2829

beets/logging.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
RootLogger,
3838
StreamHandler,
3939
)
40-
from typing import TYPE_CHECKING, Any, Mapping, TypeVar, Union, overload
40+
from typing import TYPE_CHECKING, Any, TypeVar, Union, overload
4141

4242
__all__ = [
4343
"DEBUG",
@@ -54,6 +54,8 @@
5454
]
5555

5656
if TYPE_CHECKING:
57+
from collections.abc import Mapping
58+
5759
T = TypeVar("T")
5860
from types import TracebackType
5961

beets/metadata_plugins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import abc
1111
import re
1212
from functools import cache, cached_property
13-
from typing import TYPE_CHECKING, Generic, Literal, Sequence, TypedDict, TypeVar
13+
from typing import TYPE_CHECKING, Generic, Literal, TypedDict, TypeVar
1414

1515
import unidecode
1616
from confuse import NotFoundError
@@ -22,7 +22,7 @@
2222
from .plugins import BeetsPlugin, find_plugins, notify_info_yielded, send
2323

2424
if TYPE_CHECKING:
25-
from collections.abc import Iterable
25+
from collections.abc import Iterable, Sequence
2626

2727
from .autotag.hooks import AlbumInfo, Item, TrackInfo
2828

beets/test/_common.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
import unittest
2020
from contextlib import contextmanager
2121

22-
import beets
23-
import beets.library
24-
2522
# Make sure the development versions of the plugins are used
2623
import beetsplug
2724
from beets import importer, logging, util
25+
from beets.library import Item
2826
from beets.ui import commands
2927
from beets.util import syspath
3028

@@ -99,7 +97,7 @@ def item(lib=None, **kwargs):
9997
album_id=None,
10098
mtime=12345,
10199
)
102-
i = beets.library.Item(**{**defaults, **kwargs})
100+
i = Item(**{**defaults, **kwargs})
103101
if lib:
104102
lib.add(i)
105103
return i

beets/ui/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from difflib import SequenceMatcher
3333
from functools import cache
3434
from itertools import chain
35-
from typing import Any, Callable, Literal
35+
from typing import TYPE_CHECKING, Any, Literal
3636

3737
import confuse
3838

@@ -42,6 +42,9 @@
4242
from beets.util import as_string
4343
from beets.util.functemplate import template
4444

45+
if TYPE_CHECKING:
46+
from collections.abc import Callable
47+
4548
# On Windows platforms, use colorama to support "ANSI" terminal colors.
4649
if sys.platform == "win32":
4750
try:

beets/util/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import traceback
3030
import warnings
3131
from collections import Counter
32-
from collections.abc import Sequence
32+
from collections.abc import Callable, Sequence
3333
from contextlib import suppress
3434
from enum import Enum
3535
from functools import cache
@@ -41,7 +41,6 @@
4141
TYPE_CHECKING,
4242
Any,
4343
AnyStr,
44-
Callable,
4544
ClassVar,
4645
Generic,
4746
NamedTuple,

0 commit comments

Comments
 (0)