[GH-ISSUE #960] Codebase Refactor #579

Closed
opened 2026-02-27 23:23:27 +03:00 by kerem · 3 comments
Owner

Originally created by @HighnessAtharva on GitHub (Apr 8, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/960

After glancing over the codebase, I came across code blocks that could be refactored to make them more maintainable and easier to read. Also, some refactors can make the code more "Pythonic". and performant. I have a few ideas in mind and most of them are:-

  • using if expressions than if conditions
  • list comprehensions instead of a for loop for smaller logical blocks.
  • Usage of f-strings ( I saw that the env supports 3.4 but f-strings have been added from Python 3.6). So should I refactor this?
  • Simplifying if/else code blocks to be more concise.
  • Merge nested conditional clauses.

Please let me know what Python version should be supported for these refactors and I'll get to work on it.
image

Originally created by @HighnessAtharva on GitHub (Apr 8, 2023). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/960 <!--- Please make sure you've: - read the FAQ https://github.com/plamere/spotipy/blob/master/FAQ.md - read the documentation https://spotipy.readthedocs.io/en/latest/ - searched older issues If your question is about code, please share the code you are using ---> After glancing over the codebase, I came across code blocks that could be refactored to make them more maintainable and easier to read. Also, some refactors can make the code more "Pythonic". and performant. I have a few ideas in mind and most of them are:- - using if expressions than if conditions - list comprehensions instead of a for loop for smaller logical blocks. - Usage of f-strings ( I saw that the env supports 3.4 but f-strings have been added from Python 3.6). So should I refactor this? - Simplifying if/else code blocks to be more concise. - Merge nested conditional clauses. Please let me know what Python version should be supported for these refactors and I'll get to work on it. ![image](https://user-images.githubusercontent.com/68660002/230719823-c85bba9b-3b0c-4a5c-a1a6-7457409e13f2.png)
kerem 2026-02-27 23:23:27 +03:00
Author
Owner

@HighnessAtharva commented on GitHub (Apr 8, 2023):

If possible, I think we should lift minimum Python version requirement to 3.6/3.7 since we can really improve the readability and efficiency of the code.

<!-- gh-comment-id:1500876055 --> @HighnessAtharva commented on GitHub (Apr 8, 2023): If possible, I think we should lift minimum Python version requirement to 3.6/3.7 since we can really improve the readability and efficiency of the code.
Author
Owner

@stephanebruckert commented on GitHub (Apr 8, 2023):

I think these are all great suggestions for https://github.com/spotipy-dev/spotipy/issues/652

v3 has its own branch. I would recommend that you use https://github.com/spotipy-dev/spotipy/tree/v3 and open a PR against it.

About the python support, it should be fair to only support >= 3.8 as 3.7 security support ends in June 2023 https://endoflife.date/python, so feel free to use f-strings.

Thanks for any contribution!

PS: that v3 branch is a bit out of sync with the main branch, as it needs a rebase which I have in progress. Just to let you know that conflicts may arise, but we will have all the time to fix them.

<!-- gh-comment-id:1500878096 --> @stephanebruckert commented on GitHub (Apr 8, 2023): I think these are all great suggestions for https://github.com/spotipy-dev/spotipy/issues/652 v3 has its own branch. I would recommend that you use https://github.com/spotipy-dev/spotipy/tree/v3 and open a PR against it. About the python support, it should be fair to only support >= 3.8 as 3.7 security support ends in June 2023 https://endoflife.date/python, so feel free to use f-strings. Thanks for any contribution! PS: that v3 branch is a bit out of sync with the main branch, as it needs a rebase which I have in progress. Just to let you know that conflicts may arise, but we will have all the time to fix them.
Author
Owner

@HighnessAtharva commented on GitHub (Apr 8, 2023):

Glad to heart that. I'll start working and make a PR on the v3 branch soon!

<!-- gh-comment-id:1500892810 --> @HighnessAtharva commented on GitHub (Apr 8, 2023): Glad to heart that. I'll start working and make a PR on the v3 branch soon!
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#579
No description provided.