Skip to content

Commit

Permalink
Don't make dataclasses frozen
Browse files Browse the repository at this point in the history
  • Loading branch information
7x11x13 committed Jul 8, 2024
1 parent 82e4417 commit a859bd5
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def readme():

setup(
name="soundcloud-v2",
version="1.5.1",
version="1.5.2",
description=(
"Python wrapper for the internal v2 SoundCloud API."
"Does not require an API key."
Expand Down
2 changes: 1 addition & 1 deletion soundcloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@
from soundcloud.soundcloud import *
from soundcloud.soundcloud import __all__ as sc_all

__version__ = "1.5.1"
__version__ = "1.5.2"

__all__ = sc_all + ex_all + res_all
12 changes: 6 additions & 6 deletions soundcloud/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _convert_dict(d, return_type: Type[BaseData]):
T = TypeVar("T", bound=BaseData)


@dataclass(frozen=True)
@dataclass
class Request(Generic[T]):
base = "https://api-v2.soundcloud.com"
format_url: str
Expand Down Expand Up @@ -108,7 +108,7 @@ def __call__(
return _convert_dict(r.json(), self.return_type)


@dataclass(frozen=True)
@dataclass
class CollectionRequest(Request, Generic[T]):
def __call__(
self,
Expand Down Expand Up @@ -150,7 +150,7 @@ def __call__(
resource_url = urljoin(resource_url, parsed.path)


@dataclass(frozen=True)
@dataclass
class ListRequest(Request, Generic[T]):
"""
Requests the resource list at the given url with
Expand Down Expand Up @@ -182,7 +182,7 @@ class DataclassInstance(Protocol):
Q = TypeVar("Q", bound=DataclassInstance)


@dataclass(frozen=True)
@dataclass
class GraphQLRequest(Generic[Q, T]):
base = "https://graph.soundcloud.com/graphql"
operation_name: str
Expand Down Expand Up @@ -323,13 +323,13 @@ def __call__(
"""


@dataclass(frozen=True)
@dataclass
class UserInteractionsQueryResult(BaseData):
user: Tuple[UserInteraction, ...]
creator: Tuple[UserInteraction, ...]


@dataclass(frozen=True)
@dataclass
class UserInteractionsQueryParams:
createdByProfileUrn: str
interactionTypeUrn: str
Expand Down
2 changes: 1 addition & 1 deletion soundcloud/resource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dacite import Config, from_dict


@dataclass(frozen=True)
@dataclass
class BaseData:
dacite_config = Config(
type_hooks={datetime.datetime: dateutil.parser.isoparse}, cast=[tuple]
Expand Down
2 changes: 1 addition & 1 deletion soundcloud/resource/base_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from soundcloud.resource.base import BaseData


@dataclass(frozen=True)
@dataclass
class BaseItem(BaseData):
artwork_url: Optional[str]
created_at: datetime.datetime
Expand Down
6 changes: 3 additions & 3 deletions soundcloud/resource/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from soundcloud.resource.user import BasicUser


@dataclass(frozen=True)
@dataclass
class CommentSelf(BaseData):
urn: str


@dataclass(frozen=True)
@dataclass
class BasicComment(BaseData):
"""Comment without a specified track"""

Expand All @@ -26,7 +26,7 @@ class BasicComment(BaseData):
user: BasicUser


@dataclass(frozen=True)
@dataclass
class Comment(BasicComment):
"""Comment with a specified track"""

Expand Down
2 changes: 1 addition & 1 deletion soundcloud/resource/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from soundcloud.resource.user import BasicUser, MissingUser


@dataclass(frozen=True)
@dataclass
class Conversation(BaseData):
"""DM conversation between two users"""

Expand Down
2 changes: 1 addition & 1 deletion soundcloud/resource/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from soundcloud.resource.base import BaseData


@dataclass(frozen=True)
@dataclass
class OriginalDownload(BaseData):
"""Contains a download link for a track"""

Expand Down
6 changes: 3 additions & 3 deletions soundcloud/resource/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
InteractionTypeValue = str


@dataclass(frozen=True)
@dataclass
class InteractionCount(BaseData):
count: Optional[int]
interactionTypeValueUrn: Optional[InteractionTypeValue]


@dataclass(frozen=True)
@dataclass
class UserInteraction(BaseData):
targetUrn: Optional[str]
userInteraction: Optional[InteractionTypeValue]
interactionCounts: Optional[Tuple[InteractionCount, ...]]
interactionTypeUrn: Optional[str]


@dataclass(frozen=True)
@dataclass
class CommentWithInteractions(BaseData):
comment: BasicComment
likes: int
Expand Down
2 changes: 1 addition & 1 deletion soundcloud/resource/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from soundcloud.resource.track import BasicTrack


@dataclass(frozen=True)
@dataclass
class HistoryItem(BaseData):
"""Item in user's listen history"""

Expand Down
6 changes: 3 additions & 3 deletions soundcloud/resource/like.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
from soundcloud.resource.track import BasicTrack


@dataclass(frozen=True)
@dataclass
class BaseLike(BaseData):
created_at: datetime.datetime
kind: str


@dataclass(frozen=True)
@dataclass
class TrackLike(BaseLike):
"""Like on a track"""

track: BasicTrack


@dataclass(frozen=True)
@dataclass
class PlaylistLike(BaseLike):
"""Like on a playlist"""

Expand Down
2 changes: 1 addition & 1 deletion soundcloud/resource/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from soundcloud.resource.user import BasicUser, MissingUser


@dataclass(frozen=True)
@dataclass
class Message(BaseData):
"""Single DM between two users"""

Expand Down
8 changes: 4 additions & 4 deletions soundcloud/resource/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from soundcloud.resource.user import BasicUser, User


@dataclass(frozen=True)
@dataclass
class BaseAlbumPlaylist(BaseItem):
managed_by_feeds: bool
set_type: str
Expand All @@ -18,21 +18,21 @@ class BaseAlbumPlaylist(BaseItem):
tracks: Tuple[Union[BasicTrack, MiniTrack], ...]


@dataclass(frozen=True)
@dataclass
class AlbumPlaylist(BaseAlbumPlaylist):
"""Playlist or album with full user info"""

user: User


@dataclass(frozen=True)
@dataclass
class BasicAlbumPlaylist(BaseAlbumPlaylist):
"""Playlist or album with partial user info"""

user: BasicUser


@dataclass(frozen=True)
@dataclass
class AlbumPlaylistNoTracks(BaseData):
"""Playlist or album with no track info"""

Expand Down
14 changes: 7 additions & 7 deletions soundcloud/resource/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from soundcloud.resource.user import BasicUser


@dataclass(frozen=True)
@dataclass
class BaseStreamItem(BaseData):
created_at: datetime.datetime
type: str
Expand All @@ -17,40 +17,40 @@ class BaseStreamItem(BaseData):
caption: Optional[str]


@dataclass(frozen=True)
@dataclass
class Reposted(BaseData):
target_urn: str
user_urn: str
caption: Optional[str]


@dataclass(frozen=True)
@dataclass
class BaseStreamRepostItem(BaseStreamItem):
reposted: Optional[Reposted]


@dataclass(frozen=True)
@dataclass
class TrackStreamItem(BaseStreamItem):
"""Track post in user's feed"""

track: BasicTrack


@dataclass(frozen=True)
@dataclass
class TrackStreamRepostItem(BaseStreamRepostItem):
"""Track repost in user's feed"""

track: BasicTrack


@dataclass(frozen=True)
@dataclass
class PlaylistStreamItem(BaseStreamItem):
"""Album or playlist post in user's feed"""

playlist: BasicAlbumPlaylist


@dataclass(frozen=True)
@dataclass
class PlaylistStreamRepostItem(BaseStreamRepostItem):
"""Album or playlist repost in user's feed"""

Expand Down
18 changes: 9 additions & 9 deletions soundcloud/resource/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
from soundcloud.resource.visuals import Visuals


@dataclass(frozen=True)
@dataclass
class Format(BaseData):
"""Track file format"""

protocol: str
mime_type: str


@dataclass(frozen=True)
@dataclass
class Transcoding(BaseData):
"""Available transcoding for track"""

Expand All @@ -28,14 +28,14 @@ class Transcoding(BaseData):
quality: str


@dataclass(frozen=True)
@dataclass
class Media(BaseData):
"""List of available transcodings"""

transcodings: Tuple[Transcoding, ...]


@dataclass(frozen=True)
@dataclass
class PublisherMetadata(BaseData):
"""Publisher info"""

Expand All @@ -44,7 +44,7 @@ class PublisherMetadata(BaseData):
contains_music: bool


@dataclass(frozen=True)
@dataclass
class BaseTrack(BaseItem):
caption: Optional[str]
commentable: bool
Expand All @@ -69,21 +69,21 @@ class BaseTrack(BaseItem):
policy: str


@dataclass(frozen=True)
@dataclass
class Track(BaseTrack):
"""Track with full user info"""

user: User


@dataclass(frozen=True)
@dataclass
class BasicTrack(BaseTrack):
"""Track with partial user info"""

user: BasicUser


@dataclass(frozen=True)
@dataclass
class MiniTrack(BaseData):
"""Track with minimal info"""

Expand All @@ -93,7 +93,7 @@ class MiniTrack(BaseData):
policy: str


@dataclass(frozen=True)
@dataclass
class CommentTrack(BaseData):
"""Track with partial info"""

Expand Down
Loading

0 comments on commit a859bd5

Please sign in to comment.