[PR #497] [MERGED] In '__init__' super() method should use static class name in SpotifyClientCredentials and SpotifyOAuth #916

Closed
opened 2026-02-28 00:02:37 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/spotipy-dev/spotipy/pull/497
Author: @esolitos
Created: 5/24/2020
Status: Merged
Merged: 5/25/2020
Merged by: @stephanebruckert

Base: masterHead: fix-dynamic-class-on-init


📝 Commits (1)

  • 87b2e99 In 'init' super method should use static class name

📊 Changes

1 file changed (+2 additions, -2 deletions)

View changed files

📝 spotipy/oauth2.py (+2 -2)

📄 Description

Currently it is not possible to extend SpotifyClientCredentials and SpotifyOAuth without overrding completely the __init__ method and avoid calling super().__init__().

I am not an expert in Python so I could be completely wrong, however from my research this seem to be caused from the fact that in the classes' __init__ they refer to the dynamic self.__class__, which when called by the extending class leads to to an infinite recursion.

This PR fixes the issue by setting the class name statically in the super() call.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/spotipy-dev/spotipy/pull/497 **Author:** [@esolitos](https://github.com/esolitos) **Created:** 5/24/2020 **Status:** ✅ Merged **Merged:** 5/25/2020 **Merged by:** [@stephanebruckert](https://github.com/stephanebruckert) **Base:** `master` ← **Head:** `fix-dynamic-class-on-init` --- ### 📝 Commits (1) - [`87b2e99`](https://github.com/spotipy-dev/spotipy/commit/87b2e9942aad410d60df895af6d05b0393a1b6ae) In '__init__' super method should use static class name ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `spotipy/oauth2.py` (+2 -2) </details> ### 📄 Description Currently it is not possible to extend SpotifyClientCredentials and SpotifyOAuth without overrding completely the `__init__` method and avoid calling `super().__init__()`. I am not an expert in Python so I could be completely wrong, however from my research this seem to be caused from the fact that in the classes' `__init__` they refer to the dynamic `self.__class__`, which when called by the extending class leads to to an infinite recursion. This PR fixes the issue by setting the class name statically in the `super()` call. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 00:02:37 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#916
No description provided.