From 3877b641c18c47f2875284be13c99b7000fb6e30 Mon Sep 17 00:00:00 2001 From: blissful Date: Wed, 9 Oct 2024 15:50:33 -0400 Subject: [PATCH] update linter config and fix --- conftest.py | 10 +++++----- pyproject.toml | 5 ++++- rose-cli/setup.py | 2 +- rose-py/rose/audiotags.py | 4 ++-- rose-py/rose/cache.py | 6 +++--- rose-py/rose/cache_test.py | 2 +- rose-py/rose/collages.py | 2 +- rose-py/rose/collages_test.py | 3 +-- rose-py/rose/config.py | 2 +- rose-py/rose/playlists.py | 2 +- rose-py/rose/playlists_test.py | 3 +-- rose-py/rose/releases.py | 2 +- rose-py/rose/releases_test.py | 2 +- rose-py/rose/rules.py | 2 +- rose-py/setup.py | 2 +- rose-vfs/setup.py | 2 +- rose-watch/setup.py | 2 +- 17 files changed, 27 insertions(+), 26 deletions(-) diff --git a/conftest.py b/conftest.py index f448d00..b8f2604 100644 --- a/conftest.py +++ b/conftest.py @@ -30,13 +30,13 @@ def debug_logging() -> None: logging.getLogger().setLevel(logging.DEBUG) -@pytest.fixture() +@pytest.fixture def isolated_dir() -> Iterator[Path]: with CliRunner().isolated_filesystem(): yield Path.cwd() -@pytest.fixture() +@pytest.fixture def config(isolated_dir: Path) -> Config: cache_dir = isolated_dir / "cache" cache_dir.mkdir() @@ -98,12 +98,12 @@ def config(isolated_dir: Path) -> Config: ) -@pytest.fixture() +@pytest.fixture def seeded_cache(config: Config) -> None: _seed_cache(config, True) -@pytest.fixture() +@pytest.fixture def static_cache(config: Config) -> None: """A variant of the seeded cache with static hardcoded (fake) paths. Useful for snapshot tests.""" config = dataclasses.replace(config, music_source_dir=Path("/dummy")) @@ -274,7 +274,7 @@ def _seed_cache(config: Config, mkfiles: bool) -> None: (config.music_source_dir / "!playlists" / f"{pn}.toml").touch() -@pytest.fixture() +@pytest.fixture def source_dir(config: Config) -> Path: shutil.copytree(TEST_RELEASE_1, config.music_source_dir / TEST_RELEASE_1.name) shutil.copytree(TEST_RELEASE_2, config.music_source_dir / TEST_RELEASE_2.name) diff --git a/pyproject.toml b/pyproject.toml index 34c5bc7..ef16fad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ +[project] +requires-python = ">= 3.12" + [tool.black] line-length = 120 @@ -9,7 +12,7 @@ exclude = [ ".mypy_cache", ".ruff_cache", ".venv", - "__snapshot__", + "__snapshots__", ] [tool.ruff.lint] diff --git a/rose-cli/setup.py b/rose-cli/setup.py index 58b4e1e..e070fac 100644 --- a/rose-cli/setup.py +++ b/rose-cli/setup.py @@ -6,7 +6,7 @@ setuptools.setup( name="rose-cli", version=version, - python_requires=">=3.11.0", + python_requires=">=3.12.0", author="blissful", author_email="blissful@sunsetglow.net", license="Apache-2.0", diff --git a/rose-py/rose/audiotags.py b/rose-py/rose/audiotags.py index d4852e2..1cd2131 100644 --- a/rose-py/rose/audiotags.py +++ b/rose-py/rose/audiotags.py @@ -259,7 +259,7 @@ def _get_paired_frame(x: str) -> str | None: duration_sec=round(m.info.length), # type: ignore path=p, ) - if isinstance(m, (mutagen.flac.FLAC, mutagen.oggvorbis.OggVorbis, mutagen.oggopus.OggOpus)): + if isinstance(m, mutagen.flac.FLAC | mutagen.oggvorbis.OggVorbis | mutagen.oggopus.OggOpus): return AudioTags( id=_get_tag(m.tags, ["roseid"]), release_id=_get_tag(m.tags, ["rosereleaseid"]), @@ -425,7 +425,7 @@ def _write_tag_with_description(name: str, value: str | None) -> None: m.save() return - if isinstance(m, (mutagen.flac.FLAC, mutagen.oggvorbis.OggVorbis, mutagen.oggopus.OggOpus)): + if isinstance(m, mutagen.flac.FLAC | mutagen.oggvorbis.OggVorbis | mutagen.oggopus.OggOpus): if m.tags is None: if isinstance(m, mutagen.flac.FLAC): m.tags = mutagen.flac.VCFLACDict() diff --git a/rose-py/rose/cache.py b/rose-py/rose/cache.py index 3c371ad..32f1be8 100644 --- a/rose-py/rose/cache.py +++ b/rose-py/rose/cache.py @@ -38,6 +38,7 @@ import re import sqlite3 import time +import tomllib from collections import Counter, defaultdict from collections.abc import Iterator from datetime import datetime @@ -46,7 +47,6 @@ from typing import Any, TypeVar import tomli_w -import tomllib import uuid6 from rose.audiotags import SUPPORTED_AUDIO_EXTENSIONS, AudioTags, RoseDate @@ -2438,8 +2438,8 @@ def _unpack(*xxs: str) -> Iterator[tuple[str, ...]]: # If the strings are empty, then split will resolve to `[""]`. But we don't want to loop over an # empty string, so we specially exit if we hit that case. if all(not xs for xs in xxs): - return [] - yield from zip(*[_split(xs) for xs in xxs]) + return + yield from zip(*[_split(xs) for xs in xxs], strict=False) def process_string_for_fts(x: str) -> str: diff --git a/rose-py/rose/cache_test.py b/rose-py/rose/cache_test.py index 27dd286..bc1d8a7 100644 --- a/rose-py/rose/cache_test.py +++ b/rose-py/rose/cache_test.py @@ -2,10 +2,10 @@ import hashlib import shutil import time +import tomllib from pathlib import Path import pytest -import tomllib from conftest import TEST_COLLAGE_1, TEST_PLAYLIST_1, TEST_RELEASE_1, TEST_RELEASE_2, TEST_RELEASE_3 from rose.audiotags import AudioTags, RoseDate diff --git a/rose-py/rose/collages.py b/rose-py/rose/collages.py index f558587..0aedbae 100644 --- a/rose-py/rose/collages.py +++ b/rose-py/rose/collages.py @@ -3,12 +3,12 @@ """ import logging +import tomllib from pathlib import Path from typing import Any import click import tomli_w -import tomllib from send2trash import send2trash from rose.cache import ( diff --git a/rose-py/rose/collages_test.py b/rose-py/rose/collages_test.py index d3451e9..fa89dfe 100644 --- a/rose-py/rose/collages_test.py +++ b/rose-py/rose/collages_test.py @@ -1,8 +1,7 @@ +import tomllib from pathlib import Path from typing import Any -import tomllib - from rose.cache import connect, update_cache from rose.collages import ( add_release_to_collage, diff --git a/rose-py/rose/config.py b/rose-py/rose/config.py index 1d8691b..365a7a6 100644 --- a/rose-py/rose/config.py +++ b/rose-py/rose/config.py @@ -11,6 +11,7 @@ import functools import logging import multiprocessing +import tomllib from collections import defaultdict, deque from copy import deepcopy from dataclasses import dataclass @@ -18,7 +19,6 @@ from typing import Any import appdirs -import tomllib from rose.common import RoseExpectedError from rose.rule_parser import Rule, RuleSyntaxError diff --git a/rose-py/rose/playlists.py b/rose-py/rose/playlists.py index 5f1c26e..beefd30 100644 --- a/rose-py/rose/playlists.py +++ b/rose-py/rose/playlists.py @@ -4,13 +4,13 @@ import logging import shutil +import tomllib from collections import Counter from pathlib import Path from typing import Any import click import tomli_w -import tomllib from send2trash import send2trash from rose.cache import ( diff --git a/rose-py/rose/playlists_test.py b/rose-py/rose/playlists_test.py index cafe4de..b8c180b 100644 --- a/rose-py/rose/playlists_test.py +++ b/rose-py/rose/playlists_test.py @@ -1,9 +1,8 @@ import shutil +import tomllib from pathlib import Path from typing import Any -import tomllib - from conftest import TEST_PLAYLIST_1, TEST_RELEASE_1 from rose.cache import connect, update_cache from rose.config import Config diff --git a/rose-py/rose/releases.py b/rose-py/rose/releases.py index 487b61b..fa15ce1 100644 --- a/rose-py/rose/releases.py +++ b/rose-py/rose/releases.py @@ -9,12 +9,12 @@ import re import shlex import shutil +import tomllib from dataclasses import asdict, dataclass from pathlib import Path import click import tomli_w -import tomllib from send2trash import send2trash from rose.audiotags import AudioTags, RoseDate diff --git a/rose-py/rose/releases_test.py b/rose-py/rose/releases_test.py index c2112be..7f1c602 100644 --- a/rose-py/rose/releases_test.py +++ b/rose-py/rose/releases_test.py @@ -1,10 +1,10 @@ import re import shutil +import tomllib from pathlib import Path from typing import Any import pytest -import tomllib from conftest import TEST_RELEASE_1 from rose.audiotags import AudioTags, RoseDate diff --git a/rose-py/rose/rules.py b/rose-py/rose/rules.py index 62a0c05..694153b 100644 --- a/rose-py/rose/rules.py +++ b/rose-py/rose/rules.py @@ -18,12 +18,12 @@ import re import shlex import time +import tomllib from datetime import datetime from pathlib import Path import click import tomli_w -import tomllib from rose.audiotags import AudioTags, RoseDate from rose.cache import ( diff --git a/rose-py/setup.py b/rose-py/setup.py index 48a221c..9cf24ff 100644 --- a/rose-py/setup.py +++ b/rose-py/setup.py @@ -6,7 +6,7 @@ setuptools.setup( name="rose", version=version, - python_requires=">=3.11.0", + python_requires=">=3.12.0", author="blissful", author_email="blissful@sunsetglow.net", license="Apache-2.0", diff --git a/rose-vfs/setup.py b/rose-vfs/setup.py index ab58639..ef256d2 100644 --- a/rose-vfs/setup.py +++ b/rose-vfs/setup.py @@ -6,7 +6,7 @@ setuptools.setup( name="rose-vfs", version=version, - python_requires=">=3.11.0", + python_requires=">=3.12.0", author="blissful", author_email="blissful@sunsetglow.net", license="Apache-2.0", diff --git a/rose-watch/setup.py b/rose-watch/setup.py index 93d5f2b..0300022 100644 --- a/rose-watch/setup.py +++ b/rose-watch/setup.py @@ -6,7 +6,7 @@ setuptools.setup( name="rose-watch", version=version, - python_requires=">=3.11.0", + python_requires=">=3.12.0", author="blissful", author_email="blissful@sunsetglow.net", license="Apache-2.0",