Skip to content

Commit 55a8651

Browse files
committed
build: require python3.9
For json support in sqlite.
1 parent 68f0640 commit 55a8651

27 files changed

+84
-95
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
runs-on: ${{ matrix.platform }}
3737
strategy:
3838
matrix:
39-
python-version: ["3.8", "3.9", "3.10"]
39+
python-version: ["3.9", "3.10"]
4040
platform: [ubuntu-latest, windows-latest, macos-latest]
4141

4242
steps:

docs/conf.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
https://www.sphinx-doc.org/en/master/usage/configuration.html
66
"""
77

8-
from typing import List
9-
108
import pkg_resources
119

1210
# -- Path setup --------------------------------------------------------------
@@ -62,4 +60,4 @@
6260
# Add any paths that contain custom static files (such as style sheets) here,
6361
# relative to this directory. They are copied after the builtin static files,
6462
# so a file named "default.css" will overwrite the builtin "default.css".
65-
html_static_path: List[str] = []
63+
html_static_path: list[str] = []

moe/cli.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import argparse
1010
import logging
1111
import sys
12-
from typing import List, Optional
12+
from typing import Optional
1313

1414
import pkg_resources
1515
import pluggy
@@ -101,7 +101,7 @@ def add_hooks(plugin_manager: pluggy.manager.PluginManager):
101101
plugin_manager.add_hookspecs(Hooks)
102102

103103

104-
def main(args: List[str] = sys.argv[1:], config: Optional[Config] = None):
104+
def main(args: list[str] = sys.argv[1:], config: Optional[Config] = None):
105105
"""Runs the CLI."""
106106
log.debug(f"Commandline arguments received. [{args=!r}]")
107107

@@ -118,7 +118,7 @@ def main(args: List[str] = sys.argv[1:], config: Optional[Config] = None):
118118
main()
119119

120120

121-
def _parse_args(args: List[str], config: Config):
121+
def _parse_args(args: list[str], config: Config):
122122
"""Parses the commandline arguments.
123123
124124
Args:

moe/config.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from contextlib import suppress
2121
from pathlib import Path
2222
from types import ModuleType
23-
from typing import Any, List, NamedTuple, Optional, Type, Union
23+
from typing import Any, NamedTuple, Optional, Union
2424

2525
import dynaconf
2626
import pluggy
@@ -98,7 +98,7 @@ def add_hooks(plugin_manager: pluggy.manager.PluginManager):
9898

9999
@staticmethod
100100
@moe.hookspec
101-
def edit_new_items(config: "Config", items: List[LibItem]):
101+
def edit_new_items(config: "Config", items: list[LibItem]):
102102
"""Edit any new or changed items prior to them being added to the library.
103103
104104
Args:
@@ -114,7 +114,7 @@ def edit_new_items(config: "Config", items: List[LibItem]):
114114

115115
@staticmethod
116116
@moe.hookspec
117-
def process_new_items(config: "Config", items: List[LibItem]):
117+
def process_new_items(config: "Config", items: list[LibItem]):
118118
"""Process any new or changed items after they have been added to the library.
119119
120120
Args:
@@ -191,7 +191,7 @@ class ExtraPlugin(NamedTuple):
191191
name: Name to register the plugin under.
192192
"""
193193

194-
plugin: Union[Type, ModuleType]
194+
plugin: Union[type, ModuleType]
195195
name: str
196196

197197

@@ -219,7 +219,7 @@ def __init__(
219219
self,
220220
config_dir: Path = Path.home() / ".config" / "moe", # noqa: B008
221221
settings_filename: str = "config.toml",
222-
extra_plugins: Optional[List[ExtraPlugin]] = None,
222+
extra_plugins: Optional[list[ExtraPlugin]] = None,
223223
engine: Optional[sqlalchemy.engine.base.Engine] = None,
224224
init_db=True,
225225
):

moe/library/album.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import datetime
44
import logging
55
from pathlib import Path
6-
from typing import TYPE_CHECKING, List, Optional, Tuple, Type, TypeVar, cast
6+
from typing import TYPE_CHECKING, Optional, TypeVar, cast
77

88
import sqlalchemy as sa
99
from sqlalchemy import Column, Date, Integer, String, and_, or_
@@ -46,11 +46,11 @@ class Album(LibItem, SABase):
4646
artist (str): AKA albumartist.
4747
date (datetime.date): Album release date.
4848
disc_total (int): Number of discs in the album.
49-
extras (List[Extra]): Extra non-track files associated with the album.
49+
extras (list[Extra]): Extra non-track files associated with the album.
5050
mb_album_id (str): Musicbrainz album aka release id.
5151
path (Path): Filesystem path of the album directory.
5252
title (str)
53-
tracks (List[Track]): Album's corresponding tracks.
53+
tracks (list[Track]): Album's corresponding tracks.
5454
year (int): Album release year.
5555
"""
5656

@@ -64,13 +64,13 @@ class Album(LibItem, SABase):
6464
path: Path = cast(Path, Column(PathType, nullable=False, unique=True))
6565
title: str = cast(str, Column(String, nullable=False))
6666

67-
tracks: "List[Track]" = relationship(
67+
tracks: list["Track"] = relationship(
6868
"Track",
6969
back_populates="album_obj",
7070
cascade="all, delete-orphan",
7171
collection_class=list,
7272
)
73-
extras: "List[Extra]" = relationship(
73+
extras: list["Extra"] = relationship(
7474
"Extra",
7575
back_populates="album_obj",
7676
cascade="all, delete-orphan",
@@ -109,7 +109,7 @@ def __init__(
109109
log.debug(f"Album created. [album={self!r}]")
110110

111111
@classmethod
112-
def from_dir(cls: Type[A], album_path: Path) -> A:
112+
def from_dir(cls: type[A], album_path: Path) -> A:
113113
"""Creates an album from a directory.
114114
115115
Args:
@@ -149,7 +149,7 @@ def from_dir(cls: Type[A], album_path: Path) -> A:
149149
log.debug(f"Album created from directory. [dir={album_path}, {album=!r}]")
150150
return album
151151

152-
def fields(self) -> Tuple[str, ...]:
152+
def fields(self) -> tuple[str, ...]:
153153
"""Returns the public fields, or non-method attributes, of an Album."""
154154
return (
155155
"artist",
@@ -228,7 +228,7 @@ def merge(self, other: "Album", overwrite: bool = False) -> None:
228228
if other_value and (overwrite or (not overwrite and not self_value)):
229229
setattr(self, field, other_value)
230230

231-
new_tracks: List["Track"] = []
231+
new_tracks: list[Track] = []
232232
for other_track in other.tracks:
233233
conflict_track = self.get_track(other_track.track_num, other_track.disc)
234234
if conflict_track:
@@ -237,7 +237,7 @@ def merge(self, other: "Album", overwrite: bool = False) -> None:
237237
new_tracks.append(other_track)
238238
self.tracks.extend(new_tracks)
239239

240-
new_extras: List["Extra"] = []
240+
new_extras: list[Extra] = []
241241
for other_extra in other.extras:
242242
conflict_extra = self.get_extra(other_extra.filename)
243243
if conflict_extra and overwrite:

moe/library/extra.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44
from pathlib import Path
5-
from typing import TYPE_CHECKING, Optional, Tuple, cast
5+
from typing import TYPE_CHECKING, Optional, cast
66

77
from sqlalchemy import Column, Integer
88
from sqlalchemy.orm import joinedload, relationship
@@ -60,7 +60,7 @@ def filename(self) -> str:
6060
"""Gets an Extra's filename."""
6161
return self.path.name
6262

63-
def fields(self) -> Tuple[str, ...]:
63+
def fields(self) -> tuple[str, ...]:
6464
"""Returns the public fields, or non-method attributes, of an Extra."""
6565
return "filename", "path"
6666

moe/library/lib_item.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Shared functionality between library albums, extras, and tracks."""
22

33
from pathlib import Path
4-
from typing import Tuple
54

65
import sqlalchemy as sa
76

@@ -16,7 +15,7 @@ def path(self):
1615
"""A library item's filesystem path."""
1716
raise NotImplementedError
1817

19-
def fields(self) -> Tuple[str, ...]:
18+
def fields(self) -> tuple[str, ...]:
2019
"""Returns the public attributes of an item."""
2120
raise NotImplementedError
2221

moe/library/track.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import datetime
44
import logging
55
from pathlib import Path
6-
from typing import List, Optional, Tuple, Type, TypeVar, cast
6+
from typing import Optional, TypeVar, cast
77

88
import mediafile
99
import sqlalchemy.orm as sa_orm
@@ -62,7 +62,7 @@ class Track(LibItem, SABase):
6262
disc (int): Disc number the track is on.
6363
disc_total (int): Number of discs in the album.
6464
genre (str): String of all genres concatenated with ';'.
65-
genres (List[str]): List of all genres.
65+
genres (list[str]): List of all genres.
6666
mb_album_id (str): Musicbrainz album aka release ID.
6767
mb_track_id (str): Musicbrainz track ID.
6868
path (Path): Filesystem path of the track file.
@@ -94,13 +94,13 @@ class Track(LibItem, SABase):
9494
mb_album_id: str = association_proxy("album_obj", "mb_album_id")
9595
year: int = association_proxy("album_obj", "year")
9696

97-
_genres: List[_Genre] = relationship(
97+
_genres: list[_Genre] = relationship(
9898
"_Genre",
9999
secondary=track_genre,
100100
collection_class=list,
101101
cascade="save-update, merge, expunge",
102102
)
103-
genres: List[str] = association_proxy("_genres", "name")
103+
genres: list[str] = association_proxy("_genres", "name")
104104

105105
__table_args__ = (UniqueConstraint("disc", "track_num", "_album_id"),)
106106

@@ -145,28 +145,28 @@ def _guess_disc(self) -> int:
145145
return 1
146146

147147
# The track is in a subdirectory of the album - most likely disc directories.
148-
disc_dirs: List[Path] = []
148+
disc_dirs: list[Path] = []
149149
for path in self.album_obj.path.iterdir():
150150
if not path.is_dir():
151151
continue
152152

153153
contains_tracks = False
154154
for album_track in self.album_obj.tracks:
155-
if path in album_track.path.parents:
155+
if album_track.path.is_relative_to(path):
156156
contains_tracks = True
157157

158158
if contains_tracks:
159159
disc_dirs.append(path)
160160

161161
# Guess the disc by the order of the disc directory it appears in.
162162
for disc_num, disc_dir in enumerate(sorted(disc_dirs), start=1):
163-
if disc_dir in self.path.parents:
163+
if self.path.is_relative_to(disc_dir):
164164
return disc_num
165165

166166
return 1
167167

168168
@classmethod
169-
def from_file(cls: Type[T], track_path: Path, album: Optional[Album] = None) -> T:
169+
def from_file(cls: type[T], track_path: Path, album: Optional[Album] = None) -> T:
170170
"""Alternate initializer that creates a Track from a track file.
171171
172172
Will read any tags from the given path and save them to the Track.
@@ -229,7 +229,7 @@ def genre(self, genre_str: str):
229229
"""
230230
self.genres = [genre.strip() for genre in genre_str.split(";")]
231231

232-
def fields(self) -> Tuple[str, ...]:
232+
def fields(self) -> tuple[str, ...]:
233233
"""Returns the public fields, or non-method attributes, of a Track."""
234234
return (
235235
"album",

moe/plugins/add/add_cli.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import argparse
44
import logging
55
from pathlib import Path
6-
from typing import List, Union, cast
6+
from typing import Union, cast
77

88
import moe
99
import moe.cli
@@ -18,7 +18,7 @@
1818

1919
log = logging.getLogger("moe.cli.add")
2020

21-
__all__: List[str] = []
21+
__all__: list[str] = []
2222

2323

2424
@moe.hookimpl(hookwrapper=True)

moe/plugins/info.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import argparse
1010
import logging
1111
from collections import OrderedDict
12-
from typing import Any, Dict, List
12+
from typing import Any, Dict
1313

1414
import moe
1515
import moe.cli
@@ -20,7 +20,7 @@
2020
from moe.library.track import Track
2121
from moe.query import QueryError, query
2222

23-
__all__: List[str] = []
23+
__all__: list[str] = []
2424

2525
log = logging.getLogger("moe.cli.info")
2626

@@ -68,7 +68,7 @@ def _parse_args(config: Config, args: argparse.Namespace):
6868
print(_fmt_infos(items), end="")
6969

7070

71-
def _fmt_infos(items: List[LibItem]):
71+
def _fmt_infos(items: list[LibItem]):
7272
"""Formats information for multiple items together."""
7373
out_str = ""
7474
for item in items:

moe/plugins/list.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66

77
import argparse
88
import logging
9-
from typing import List
109

1110
import moe
1211
import moe.cli
1312
from moe.config import Config
1413
from moe.query import QueryError, query
1514

16-
__all__: List[str] = []
15+
__all__: list[str] = []
1716

1817
log = logging.getLogger("moe.cli.list")
1918

moe/plugins/moe_import/import_cli.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Import prompt."""
22

33
import logging
4-
from typing import List
54

65
import pluggy
76

@@ -26,7 +25,7 @@ class Hooks:
2625

2726
@staticmethod
2827
@moe.hookspec
29-
def add_import_prompt_choice(prompt_choices: List[PromptChoice]):
28+
def add_import_prompt_choice(prompt_choices: list[PromptChoice]):
3029
"""Add a user input choice to the import prompt.
3130
3231
``func`` should return the album to be added to the library (or ``None`` if no
@@ -76,7 +75,7 @@ def process_candidates(config: Config, old_album: Album, candidates):
7675

7776

7877
@moe.hookimpl
79-
def add_import_prompt_choice(prompt_choices: List[PromptChoice]):
78+
def add_import_prompt_choice(prompt_choices: list[PromptChoice]):
8079
"""Adds the ``apply`` and ``abort`` prompt choices to the user prompt."""
8180
prompt_choices.append(
8281
PromptChoice(title="Apply changes", shortcut_key="a", func=_apply_changes)
@@ -106,7 +105,7 @@ def import_prompt(
106105

107106
print(fmt_album_changes(old_album, new_album))
108107

109-
prompt_choices: List[PromptChoice] = []
108+
prompt_choices: list[PromptChoice] = []
110109
config.plugin_manager.hook.add_import_prompt_choice(prompt_choices=prompt_choices)
111110

112111
prompt_choice = choice_prompt(prompt_choices)

moe/plugins/moe_import/import_core.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Core api for importing albums."""
22

33
import logging
4-
from typing import List
54

65
import pluggy
76

@@ -42,7 +41,7 @@ def import_candidates(config: Config, album: Album) -> Album: # type: ignore
4241

4342
@staticmethod
4443
@moe.hookspec
45-
def process_candidates(config: Config, old_album: Album, candidates: List[Album]):
44+
def process_candidates(config: Config, old_album: Album, candidates: list[Album]):
4645
"""Process the imported candidate albums.
4746
4847
If you wish to save and apply any candidate album metadata, it should be applied

0 commit comments

Comments
 (0)