Skip to content

Commit

Permalink
update linter config and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed Oct 9, 2024
1 parent 1c6f860 commit 3877b64
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 26 deletions.
10 changes: 5 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[project]
requires-python = ">= 3.12"

[tool.black]
line-length = 120

Expand All @@ -9,7 +12,7 @@ exclude = [
".mypy_cache",
".ruff_cache",
".venv",
"__snapshot__",
"__snapshots__",
]

[tool.ruff.lint]
Expand Down
2 changes: 1 addition & 1 deletion rose-cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions rose-py/rose/audiotags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions rose-py/rose/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion rose-py/rose/cache_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rose-py/rose/collages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
3 changes: 1 addition & 2 deletions rose-py/rose/collages_test.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion rose-py/rose/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import functools
import logging
import multiprocessing
import tomllib
from collections import defaultdict, deque
from copy import deepcopy
from dataclasses import dataclass
from pathlib import Path
from typing import Any

import appdirs
import tomllib

from rose.common import RoseExpectedError
from rose.rule_parser import Rule, RuleSyntaxError
Expand Down
2 changes: 1 addition & 1 deletion rose-py/rose/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
3 changes: 1 addition & 2 deletions rose-py/rose/playlists_test.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion rose-py/rose/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rose-py/rose/releases_test.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion rose-py/rose/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion rose-py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion rose-vfs/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion rose-watch/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3877b64

Please sign in to comment.