From 429524263bb0d2e58ae7845a3219b3503daf150f Mon Sep 17 00:00:00 2001 From: Antoine Gibek Date: Tue, 23 Jan 2024 14:03:21 +0100 Subject: [PATCH] refactor: Change enums names --- docs/source/get-started/get-started.md | 6 +++--- fretboardgtr/constants.py | 18 +++++++++--------- fretboardgtr/notes_creators.py | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/source/get-started/get-started.md b/docs/source/get-started/get-started.md index 5c5d3a2..ec9f065 100644 --- a/docs/source/get-started/get-started.md +++ b/docs/source/get-started/get-started.md @@ -123,7 +123,7 @@ from fretboardgtr.notes_creators import ChordFromName TUNING = ["E", "A", "D", "G", "B", "E"] ROOT = "C" -QUALITY = Chord.MAJOR +QUALITY = ChordName.MAJOR fingerings = ( ChordFromName(root=ROOT, quality=QUALITY).build().get_chord_fingerings(TUNING) @@ -190,11 +190,11 @@ And so on. ```python from fretboardgtr.fretboard import FretBoardConfig, FretBoard from fretboardgtr.notes_creators import ScaleFromName -from fretboardgtr.constants import Mode +from fretboardgtr.constants import ModeName TUNING = ["E", "A", "D", "G", "B", "E"] ROOT = "A" -MODE = Mode.MINOR_PENTATONIC +MODE = ModeName.MINOR_PENTATONIC scale_positions = ( ScaleFromName(root=ROOT, mode=MODE).build().get_scale_positions(TUNING, max_spacing=4) diff --git a/fretboardgtr/constants.py b/fretboardgtr/constants.py index 199855e..78e2650 100644 --- a/fretboardgtr/constants.py +++ b/fretboardgtr/constants.py @@ -3,11 +3,11 @@ from enum import Enum -class Mode(str, Enum): +class ModeName(str, Enum): """Makes it easier to list and select a mode. - One can use auto-completion Mode.MIXOLYDIAN can be used instead of - the 'Mixolydian' literal string. + One can use auto-completion ModeName.MIXOLYDIAN can be used instead + of the 'Mixolydian' literal string. """ AEOLIAN = "Aeolian" @@ -78,13 +78,13 @@ class Mode(str, Enum): } -class Chord(str, Enum): +class ChordName(str, Enum): """Makes it easier to list and select a chord. - One can use auto-completion Chord.MAJOR can be used instead of the 'M' + One can use auto-completion ChordName.MAJOR can be used instead of the 'M' literal string. - Not every defined Chord from CHORDS_DICT_ESSENTIAL is defined as an + Not every defined ChordName from CHORDS_DICT_ESSENTIAL is defined as an enum here, only the most common ones. """ @@ -187,11 +187,11 @@ class Chord(str, Enum): } -class Note(str, Enum): +class NoteName(str, Enum): """Makes it easier to list and select a note. - One can use auto-completion Note.A_SHARP instead of the 'A#' literal - string. + One can use auto-completion NoteName.A_SHARP instead of the 'A#' + literal string. """ A = "A" diff --git a/fretboardgtr/notes_creators.py b/fretboardgtr/notes_creators.py index ee632aa..8c48655 100644 --- a/fretboardgtr/notes_creators.py +++ b/fretboardgtr/notes_creators.py @@ -162,14 +162,14 @@ class ScaleFromName: Given a root name and a mode name, get the resulting scale. Also : - Mode name can be given thanks to the constants.Mode enum as well as string - Note name can be given thanks to the constants.Note enum as well as string + Mode name can be given thanks to the constants.ModeName enum as well as string + Note name can be given thanks to the constants.NoteName enum as well as string Example ------- >>> ScaleFromName(root='C',mode='Dorian').build() NotesContainer(root= 'C', scale = ['C', 'D', 'D#', 'F', 'G', 'A', 'A#']) - >>> ScaleFromName(root=Note.C,mode=Mode.DORIAN).build() + >>> ScaleFromName(root=Name.C,mode=ModeName.DORIAN).build() NotesContainer(root= 'C', scale = ['C', 'D', 'D#', 'F', 'G', 'A', 'A#']) """ @@ -192,14 +192,14 @@ class ChordFromName: Given a root name and a quality name, get the resulting scale. Also : - Mode name can be given thanks to the constants.Chord enum as well as string - Note name can be given thanks to the constants.Note enum as well as string + Mode name can be given thanks to the constants.ChordName enum as well as string + Note name can be given thanks to the constants.NoteName enum as well as string Example ------- >>> ChordFromName(root='C',quality='M').build() NotesContainer(root= 'C', scale = ['C', 'E', 'G']) - >>> ChordFromName(root=Note.C,quality=Chord.MAJOR).build() + >>> ChordFromName(root=NoteName.C,quality=ChordName.MAJOR).build() NotesContainer(root= 'C', scale = ['C', 'E', 'G']) """