Skip to content

Commit

Permalink
Merge pull request #105 from geigerzaehler/require-python-310
Browse files Browse the repository at this point in the history
Require Python 3.10
  • Loading branch information
geigerzaehler authored Oct 30, 2024
2 parents f513921 + 1a479ee commit e86af1e
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 280 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ jobs:
matrix:
os: ["ubuntu-latest"]
python-version:
- "3.8" # minimum required
- "3.12" # latest
- "3.13-dev" # next
- "3.10" # minimum required
- "3.13" # latest
include:
- python-version: 3.8
- python-version: "3.10"
os: windows-2022
- python-version: 3.8
- python-version: "3.10"
os: macos-12

runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.python-version == '3.13-dev' }}
# Fails because of https://github.com/beetbox/mediafile/pull/75
continue-on-error: ${{ matrix.python-version == '3.13' }}

steps:
- uses: actions/checkout@v4
Expand All @@ -41,7 +41,7 @@ jobs:
- uses: coverallsapp/github-action@v2
if: >
(github.event_name == 'pull_request' || github.ref_name == 'main') &&
matrix.python-version == '3.8' &&
matrix.python-version == '3.10' &&
matrix.os == 'ubuntu-latest'
with:
# Ignore .coverage, which has limited support from coveralls
Expand All @@ -60,7 +60,7 @@ jobs:
- run: pip install poetry
- uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: "3.10"
cache: poetry
- run: poetry env use $(which python)
- run: poetry install
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Change Log
* Consistently use Unicode paths to alternative items. This may result and
collection updates and orphaned files in alternatives. It may also improve
usability on non-standard file systems (see [#74]).
* Require Python >= 3.10

[#74]: https://github.com/geigerzaehler/beets-alternatives/issues/74

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ documentation](./DEVELOPING.md).
Getting Started
---------------

Install the plugin and make sure you using at least version 1.6.0 of beets and
Python 3.8.
Install the plugin and make sure you using at least version 1.6.1 of beets and
Python 3.10.

```bash
pip install --upgrade beets>=1.6.0 beets-alternatives
Expand Down
16 changes: 8 additions & 8 deletions beetsplug/alternatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import os.path
import shutil
import threading
from collections.abc import Callable, Iterable, Iterator, Sequence
from concurrent import futures
from enum import Enum
from pathlib import Path
from typing import Callable, Iterable, Iterator, Optional, Sequence, Set, Tuple

import beets
import confuse
Expand Down Expand Up @@ -229,7 +229,7 @@ def _matched_item_action(self, item: Item) -> Sequence[Action]:
else:
return [Action.ADD]

def _items_actions(self) -> Iterator[Tuple[Item, Sequence[Action]]]:
def _items_actions(self) -> Iterator[tuple[Item, Sequence[Action]]]:
matched_ids = set()
for album in self.lib.albums():
if self.query.match(album):
Expand All @@ -242,7 +242,7 @@ def _items_actions(self) -> Iterator[Tuple[Item, Sequence[Action]]]:
elif self._get_stored_path(item):
yield (item, [Action.REMOVE])

def ask_create(self, create: Optional[bool] = None) -> bool:
def ask_create(self, create: bool | None = None) -> bool:
if not self.removable:
return True
if create is not None:
Expand All @@ -255,7 +255,7 @@ def ask_create(self, create: Optional[bool] = None) -> bool:
)
return input_yn(msg, require=True)

def update(self, create: Optional[bool] = None):
def update(self, create: bool | None = None):
if not self.directory.is_dir() and not self.ask_create(create):
print_(f"Skipping creation of {self.directory}")
return
Expand Down Expand Up @@ -308,7 +308,7 @@ def destination(self, item: Item) -> Path:
def _set_stored_path(self, item: Item, path: Path):
item[self.path_key] = str(path)

def _get_stored_path(self, item: Item) -> Optional[Path]:
def _get_stored_path(self, item: Item) -> Path | None:
try:
path = item[self.path_key]
except KeyError:
Expand Down Expand Up @@ -435,7 +435,7 @@ def item_change_actions(
return [Action.MOVE]

@override
def update(self, create: Optional[bool] = None):
def update(self, create: bool | None = None):
for item, actions in self._items_actions():
dest = self.destination(item)
path = self._get_stored_path(item)
Expand Down Expand Up @@ -476,10 +476,10 @@ def _sync_art(self, item: Item, path: Path):

class Worker(futures.ThreadPoolExecutor):
def __init__(
self, fn: Callable[[Item], Tuple[Item, Path]], max_workers: Optional[int]
self, fn: Callable[[Item], tuple[Item, Path]], max_workers: int | None
):
super().__init__(max_workers)
self._tasks: Set[futures.Future[Tuple[Item, Path]]] = set()
self._tasks: set[futures.Future[tuple[Item, Path]]] = set()
self._fn = fn

def run(self, item: Item):
Expand Down
Loading

0 comments on commit e86af1e

Please sign in to comment.