From 161b0522bbf7f4984173fee4128416b05f6cc5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Sun, 17 Nov 2024 06:40:21 +0000 Subject: [PATCH] Update deprecated imports --- beets/autotag/__init__.py | 3 ++- beets/autotag/hooks.py | 3 ++- beets/autotag/match.py | 3 ++- beets/autotag/mb.py | 3 ++- beets/dbcore/db.py | 17 +++-------------- beets/dbcore/query.py | 15 +++------------ beets/dbcore/queryparse.py | 2 +- beets/ui/commands.py | 3 ++- beets/util/__init__.py | 5 ++--- beetsplug/aura.py | 3 ++- beetsplug/autobpm.py | 2 +- beetsplug/playlist.py | 2 +- beetsplug/replaygain.py | 3 ++- test/plugins/test_albumtypes.py | 2 +- test/plugins/test_hook.py | 3 ++- 15 files changed, 28 insertions(+), 41 deletions(-) diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index c6f65ee49..70814c182 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -14,7 +14,8 @@ """Facilities for automatically determining files' correct metadata.""" -from typing import Mapping, Sequence, Union +from collections.abc import Mapping, Sequence +from typing import Union from beets import config, logging from beets.library import Album, Item diff --git a/beets/autotag/hooks.py b/beets/autotag/hooks.py index a458d58eb..780bbcc3a 100644 --- a/beets/autotag/hooks.py +++ b/beets/autotag/hooks.py @@ -17,8 +17,9 @@ from __future__ import annotations import re +from collections.abc import Iterable, Iterator from functools import total_ordering -from typing import Any, Callable, Iterable, Iterator, NamedTuple, TypeVar, cast +from typing import Any, Callable, NamedTuple, TypeVar, cast from jellyfish import levenshtein_distance from unidecode import unidecode diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 06893f5ca..a9df116e5 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -20,8 +20,9 @@ from __future__ import annotations import datetime import re +from collections.abc import Iterable, Sequence from enum import IntEnum -from typing import Any, Iterable, NamedTuple, Sequence, TypeVar, Union, cast +from typing import Any, NamedTuple, TypeVar, Union, cast from munkres import Munkres diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py index 084610772..90c2013d8 100644 --- a/beets/autotag/mb.py +++ b/beets/autotag/mb.py @@ -19,8 +19,9 @@ from __future__ import annotations import re import traceback from collections import Counter +from collections.abc import Iterator, Sequence from itertools import product -from typing import Any, Iterator, Sequence, cast +from typing import Any, cast from urllib.parse import urljoin import musicbrainzngs diff --git a/beets/dbcore/db.py b/beets/dbcore/db.py index 407983d24..df2cbc099 100755 --- a/beets/dbcore/db.py +++ b/beets/dbcore/db.py @@ -24,21 +24,10 @@ import threading import time from abc import ABC from collections import defaultdict +from collections.abc import Generator, Iterable, Iterator, Mapping, Sequence from sqlite3 import Connection from types import TracebackType -from typing import ( - Any, - AnyStr, - Callable, - Generator, - Generic, - Iterable, - Iterator, - Mapping, - Sequence, - TypeVar, - cast, -) +from typing import Any, AnyStr, Callable, Generic, TypeVar, cast from unidecode import unidecode @@ -1131,7 +1120,7 @@ class Database: conn.close() @contextlib.contextmanager - def _tx_stack(self) -> Generator[list, None, None]: + def _tx_stack(self) -> Generator[list]: """A context manager providing access to the current thread's transaction stack. The context manager synchronizes access to the stack map. Transactions should never migrate across threads. diff --git a/beets/dbcore/query.py b/beets/dbcore/query.py index e1e4a98e0..0b52b0f22 100644 --- a/beets/dbcore/query.py +++ b/beets/dbcore/query.py @@ -19,21 +19,12 @@ from __future__ import annotations import re import unicodedata from abc import ABC, abstractmethod +from collections.abc import Collection, Iterator, MutableSequence, Sequence from datetime import datetime, timedelta from functools import reduce from operator import mul, or_ -from typing import ( - TYPE_CHECKING, - Any, - Collection, - Generic, - Iterator, - MutableSequence, - Pattern, - Sequence, - TypeVar, - Union, -) +from re import Pattern +from typing import TYPE_CHECKING, Any, Generic, TypeVar, Union from beets import util diff --git a/beets/dbcore/queryparse.py b/beets/dbcore/queryparse.py index d35fec0e3..5335d64c0 100644 --- a/beets/dbcore/queryparse.py +++ b/beets/dbcore/queryparse.py @@ -18,7 +18,7 @@ from __future__ import annotations import itertools import re -from typing import Collection, Sequence +from collections.abc import Collection, Sequence from . import Model, query from .query import Sort diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 9ad19ad05..99aa04f0a 100755 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -19,9 +19,10 @@ interface. import os import re from collections import Counter +from collections.abc import Sequence from itertools import chain from platform import python_version -from typing import Any, NamedTuple, Sequence +from typing import Any, NamedTuple import beets from beets import autotag, config, importer, library, logging, plugins, ui, util diff --git a/beets/util/__init__.py b/beets/util/__init__.py index e45f92fb7..a929a3f7f 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -28,20 +28,19 @@ import sys import tempfile import traceback from collections import Counter +from collections.abc import Iterator, Sequence from contextlib import suppress from enum import Enum from importlib import import_module from multiprocessing.pool import ThreadPool from pathlib import Path +from re import Pattern from typing import ( TYPE_CHECKING, Any, AnyStr, Callable, - Iterator, NamedTuple, - Pattern, - Sequence, TypeVar, Union, ) diff --git a/beetsplug/aura.py b/beetsplug/aura.py index 7c68a7607..a9b270657 100644 --- a/beetsplug/aura.py +++ b/beetsplug/aura.py @@ -17,9 +17,10 @@ import os import re import sys +from collections.abc import Mapping from dataclasses import dataclass from mimetypes import guess_type -from typing import ClassVar, Mapping +from typing import ClassVar from flask import ( Blueprint, diff --git a/beetsplug/autobpm.py b/beetsplug/autobpm.py index 0262f03c2..96eccfb7b 100644 --- a/beetsplug/autobpm.py +++ b/beetsplug/autobpm.py @@ -15,7 +15,7 @@ from __future__ import annotations -from typing import Iterable +from collections.abc import Iterable import librosa diff --git a/beetsplug/playlist.py b/beetsplug/playlist.py index 83f95796e..cf1d500e8 100644 --- a/beetsplug/playlist.py +++ b/beetsplug/playlist.py @@ -15,7 +15,7 @@ import fnmatch import os import tempfile -from typing import Sequence +from collections.abc import Sequence import beets from beets.dbcore.query import InQuery diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py index 137ff0e49..964b6d0a3 100644 --- a/beetsplug/replaygain.py +++ b/beetsplug/replaygain.py @@ -26,11 +26,12 @@ import subprocess import sys import warnings from abc import ABC, abstractmethod +from collections.abc import Sequence from dataclasses import dataclass from logging import Logger from multiprocessing.pool import ThreadPool from threading import Event, Thread -from typing import Any, Callable, Sequence, TypeVar, cast +from typing import Any, Callable, TypeVar, cast from confuse import ConfigView diff --git a/test/plugins/test_albumtypes.py b/test/plugins/test_albumtypes.py index 10ec74181..8be1ff011 100644 --- a/test/plugins/test_albumtypes.py +++ b/test/plugins/test_albumtypes.py @@ -14,7 +14,7 @@ """Tests for the 'albumtypes' plugin.""" -from typing import Sequence +from collections.abc import Sequence from beets.autotag.mb import VARIOUS_ARTISTS_ID from beets.test.helper import PluginTestCase diff --git a/test/plugins/test_hook.py b/test/plugins/test_hook.py index c531cd8c6..d9de15283 100644 --- a/test/plugins/test_hook.py +++ b/test/plugins/test_hook.py @@ -18,8 +18,9 @@ from __future__ import annotations import os.path import sys import unittest +from collections.abc import Iterator from contextlib import contextmanager -from typing import Callable, Iterator +from typing import Callable from beets import plugins from beets.test.helper import PluginTestCase, capture_log