fixed mutable argument bug in the source dict of SourceAttribute

This commit is contained in:
Hellow2
2023-01-31 13:18:52 +01:00
parent ae9a70fb04
commit 2e6c58255c
7 changed files with 125 additions and 3 deletions

View File

@@ -329,6 +329,7 @@ class Database:
for source in artist.source_list:
source.type_enum = SourceTypes.ARTIST
source.add_song(artist)
self.push_source(source)
def pull_lyrics(self, song_ref: Reference = None, lyrics_ref: Reference = None) -> List[Lyrics]:

View File

@@ -362,10 +362,15 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
main_songs: List[Song] = None,
feature_songs: List[Song] = None,
main_albums: List[Album] = None,
album_type: str = None,
notes: str = None
):
DatabaseObject.__init__(self, id_=id_)
"""
TODO implement album type and notes
"""
self.album_type = album_type
self.notes = notes
if main_albums is None:
@@ -391,6 +396,9 @@ class Artist(DatabaseObject, SourceAttribute, MetadataAttribute):
def __repr__(self):
return self.__str__()
def __eq__(self, __o: object) -> bool:
return self.id_ == __o.id_
def get_features(self) -> Album:
feature_release = Album(
title="features",

View File

@@ -88,7 +88,12 @@ class SourceAttribute:
This is a class that is meant to be inherited from.
it adds the source_list attribute to a class
"""
_source_dict: Dict[object, List[Source]] = {page_enum: list() for page_enum in SourcePages}
_source_dict: Dict[object, List[Source]]
def __new__(cls, **_):
new = object.__new__(cls)
new._source_dict = {page_enum: list() for page_enum in SourcePages}
return new
def add_source(self, source: Source):
"""