Skip to content

Commit 43ef604

Browse files
committed
Run pyupgrade on the source
1 parent 641c963 commit 43ef604

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: v3.3.1
44
hooks:
55
- id: pyupgrade
6-
args: [--py37-plus]
6+
args: [--py39-plus]
77

88
- repo: https://github.com/PyCQA/flake8
99
rev: 6.0.0

guitarpro/models.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from collections.abc import Callable
12
from enum import Enum, IntEnum
23
from fractions import Fraction
34
from functools import partial
45
from math import log
5-
from typing import Any, Callable, List, Optional, Tuple, TypeVar, Union, overload
6+
from typing import Any, Optional, TypeVar, Union, overload
67

78
import attr
89

@@ -60,7 +61,7 @@ def __dataclass_transform__(
6061
eq_default: bool = True,
6162
order_default: bool = False,
6263
kw_only_default: bool = False,
63-
field_descriptors: Tuple[Union[type, Callable[..., Any]], ...] = (()),
64+
field_descriptors: tuple[Union[type, Callable[..., Any]], ...] = (()),
6465
) -> Callable[[_T], _T]:
6566
return lambda a: a
6667

@@ -103,9 +104,9 @@ class RepeatGroup:
103104
which are repeated.
104105
"""
105106

106-
measureHeaders: List['MeasureHeader'] = attr.Factory(list)
107-
closings: List['MeasureHeader'] = attr.Factory(list)
108-
openings: List['MeasureHeader'] = attr.Factory(list)
107+
measureHeaders: list['MeasureHeader'] = attr.Factory(list)
108+
closings: list['MeasureHeader'] = attr.Factory(list)
109+
openings: list['MeasureHeader'] = attr.Factory(list)
109110
isClosed: bool = False
110111

111112
def addMeasureHeader(self, h):
@@ -187,7 +188,7 @@ class Lyrics:
187188
"""A collection of lyrics lines for a track."""
188189

189190
trackChoice: int = 0
190-
lines: List[LyricLine] = attr.Factory(lambda: [LyricLine() for _ in range(Lyrics.maxLineCount)])
191+
lines: list[LyricLine] = attr.Factory(lambda: [LyricLine() for _ in range(Lyrics.maxLineCount)])
191192

192193
maxLineCount = 5
193194

@@ -290,7 +291,7 @@ class RSEEqualizer:
290291
5.
291292
"""
292293

293-
knobs: List[float] = attr.Factory(list)
294+
knobs: list[float] = attr.Factory(list)
294295
gain: float = attr.ib(default=0.0)
295296

296297

@@ -315,7 +316,7 @@ class Song:
315316
"""
316317

317318
# TODO: Store file format version here
318-
versionTuple: Optional[Tuple[int, int, int]] = attr.ib(default=None, hash=False, eq=False)
319+
versionTuple: Optional[tuple[int, int, int]] = attr.ib(default=None, hash=False, eq=False)
319320
clipboard: Optional[Clipboard] = None
320321
title: str = ''
321322
subtitle: str = ''
@@ -326,15 +327,15 @@ class Song:
326327
copyright: str = ''
327328
tab: str = ''
328329
instructions: str = ''
329-
notice: List[str] = attr.Factory(list)
330+
notice: list[str] = attr.Factory(list)
330331
lyrics: Lyrics = attr.Factory(Lyrics)
331332
pageSetup: PageSetup = attr.Factory(PageSetup)
332333
tempoName: str = 'Moderate'
333334
tempo: int = 120
334335
hideTempo: bool = False
335336
key: KeySignature = KeySignature.CMajor
336-
measureHeaders: List['MeasureHeader'] = attr.Factory(lambda: [MeasureHeader()])
337-
tracks: List['Track'] = attr.Factory(lambda self: [Track(self)], takes_self=True)
337+
measureHeaders: list['MeasureHeader'] = attr.Factory(lambda: [MeasureHeader()])
338+
tracks: list['Track'] = attr.Factory(lambda self: [Track(self)], takes_self=True)
338339
masterEffect: RSEMasterEffect = attr.Factory(RSEMasterEffect)
339340

340341
_currentRepeatGroup: RepeatGroup = attr.ib(default=attr.Factory(RepeatGroup), hash=False, eq=False, repr=False)
@@ -489,7 +490,7 @@ class TimeSignature:
489490

490491
numerator: int = 4
491492
denominator: Duration = attr.Factory(Duration)
492-
beams: List[int] = attr.Factory(list)
493+
beams: list[int] = attr.Factory(list)
493494

494495
def __attrs_post_init__(self):
495496
if not self.beams:
@@ -637,10 +638,10 @@ class Track:
637638
isMute: bool = False
638639
indicateTuning: bool = False
639640
name: str = 'Track 1'
640-
measures: List['Measure'] = attr.Factory(lambda self: [Measure(self, header)
641+
measures: list['Measure'] = attr.Factory(lambda self: [Measure(self, header)
641642
for header in self.song.measureHeaders],
642643
takes_self=True)
643-
strings: List['GuitarString'] = attr.Factory(lambda: [GuitarString(n, v)
644+
strings: list['GuitarString'] = attr.Factory(lambda: [GuitarString(n, v)
644645
for n, v in [(1, 64), (2, 59), (3, 55),
645646
(4, 50), (5, 45), (6, 40)]])
646647
port: int = 1
@@ -691,7 +692,7 @@ class Measure:
691692
track: Track = attr.ib(hash=False, eq=False, repr=False)
692693
header: MeasureHeader = attr.ib(hash=False, eq=False, repr=False)
693694
clef: MeasureClef = MeasureClef.treble
694-
voices: List['Voice'] = attr.Factory(lambda self: [Voice(self) for _ in range(self.maxVoices)], takes_self=True)
695+
voices: list['Voice'] = attr.Factory(lambda self: [Voice(self) for _ in range(self.maxVoices)], takes_self=True)
695696
lineBreak: LineBreak = LineBreak.none
696697

697698
maxVoices = 2
@@ -736,7 +737,7 @@ class Voice:
736737
"""A voice contains multiple beats."""
737738

738739
measure: Measure = attr.ib(hash=False, eq=False, repr=False)
739-
beats: List['Beat'] = attr.Factory(list)
740+
beats: list['Beat'] = attr.Factory(list)
740741
direction: VoiceDirection = VoiceDirection.none
741742

742743
@property
@@ -865,7 +866,7 @@ class Beat:
865866
"""A beat contains multiple notes."""
866867

867868
voice: Voice = attr.ib(hash=False, eq=False, repr=False)
868-
notes: List['Note'] = attr.Factory(list)
869+
notes: list['Note'] = attr.Factory(list)
869870
duration: Duration = attr.Factory(Duration)
870871
text: Optional[str] = None
871872
start: Optional[int] = attr.ib(default=None, hash=False, eq=False)
@@ -1045,7 +1046,7 @@ class NoteEffect:
10451046
letRing: bool = False
10461047
palmMute: bool = False
10471048
rightHandFinger: Fingering = Fingering.open
1048-
slides: List[SlideType] = attr.Factory(list)
1049+
slides: list[SlideType] = attr.Factory(list)
10491050
staccato: bool = False
10501051
tremoloPicking: Optional[TremoloPickingEffect] = None
10511052
trill: Optional[TrillEffect] = None
@@ -1136,10 +1137,10 @@ class Chord:
11361137
ninth: Optional['ChordAlteration'] = None
11371138
eleventh: Optional['ChordAlteration'] = None
11381139
firstFret: Optional[int] = None
1139-
strings: List[int] = attr.Factory(lambda self: [-1] * self.length, takes_self=True)
1140-
barres: List['Barre'] = attr.Factory(list)
1141-
omissions: List[bool] = attr.Factory(list)
1142-
fingerings: List[Fingering] = attr.Factory(list)
1140+
strings: list[int] = attr.Factory(lambda self: [-1] * self.length, takes_self=True)
1141+
barres: list['Barre'] = attr.Factory(list)
1142+
omissions: list[bool] = attr.Factory(list)
1143+
fingerings: list[Fingering] = attr.Factory(list)
11431144
show: Optional[bool] = None
11441145
newFormat: Optional[bool] = None
11451146

@@ -1469,7 +1470,7 @@ class BendEffect:
14691470

14701471
type: BendType = BendType.none
14711472
value: int = 0
1472-
points: List[BendPoint] = attr.Factory(list)
1473+
points: list[BendPoint] = attr.Factory(list)
14731474

14741475
#: The note offset per bend point offset.
14751476
semitoneLength = 1

0 commit comments

Comments
 (0)