Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add PaginationList to improve how we deal with pagination #425

Merged
merged 26 commits into from
Jan 17, 2022

Conversation

browniebroke
Copy link
Owner

@browniebroke browniebroke commented Jan 5, 2022

Inspired by pagination from PyGithub and I liked how they do it

  • Add new PaginationList class with basic features: iterable + total count
  • Update existing code to use it
  • Update existing tests
  • Add new tests to cover edge cases
  • Update documentation
  • Make sure that the change is flagged as breaking

Fix #137

@browniebroke browniebroke force-pushed the feat/pagination branch 2 times, most recently from f9f408a to ec7ed3c Compare January 6, 2022 18:32
@browniebroke browniebroke changed the base branch from main to remove/tornado-client January 6, 2022 18:32
@codecov
Copy link

codecov bot commented Jan 6, 2022

Codecov Report

Merging #425 (56e9a2a) into main (96df7b8) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #425   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            5         6    +1     
  Lines          476       500   +24     
  Branches        35        40    +5     
=========================================
+ Hits           476       500   +24     
Impacted Files Coverage Δ
deezer/__init__.py 100.00% <100.00%> (ø)
deezer/client.py 100.00% <100.00%> (ø)
deezer/pagination.py 100.00% <100.00%> (ø)
deezer/resources.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96df7b8...56e9a2a. Read the comment docs.

@browniebroke browniebroke marked this pull request as ready for review January 17, 2022 10:49
Base automatically changed from remove/tornado-client to main January 17, 2022 12:29
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 17, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 1.83%.

Quality metrics Before After Change
Complexity 1.02 ⭐ 1.00 ⭐ -0.02 👍
Method Length 28.71 ⭐ 26.13 ⭐ -2.58 👍
Working memory 4.34 ⭐ 4.12 ⭐ -0.22 👍
Quality 89.87% 91.70% 1.83% 👍
Other metrics Before After Change
Lines 1675 1343 -332
Changed files Quality Before Quality After Quality Change
conftest.py 90.62% ⭐ 90.62% ⭐ 0.00%
deezer/init.py 83.52% ⭐ 83.03% ⭐ -0.49% 👎
deezer/client.py 81.51% ⭐ 81.89% ⭐ 0.38% 👍
deezer/resources.py 93.26% ⭐ 91.78% ⭐ -1.48% 👎
tests/test_client.py 94.48% ⭐ 94.61% ⭐ 0.13% 👍
tests/test_resources.py 88.70% ⭐ 95.00% ⭐ 6.30% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
deezer/client.py Client._process_json 15 🙂 127 😞 10 😞 51.46% 🙂 Try splitting into smaller methods. Extract out complex expressions
deezer/client.py Client.request 4 ⭐ 90 🙂 10 😞 66.42% 🙂 Extract out complex expressions
deezer/client.py Client.search 0 ⭐ 54 ⭐ 14 😞 69.24% 🙂 Extract out complex expressions
tests/test_client.py TestClient.test_process_json_types 0 ⭐ 130 😞 7 🙂 71.78% 🙂 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@browniebroke browniebroke changed the title feat: add pagination list to deal with paginated responses feat: add PaginationList to improve how we deal with pagination Jan 17, 2022
@browniebroke browniebroke merged commit 6a4ccf2 into main Jan 17, 2022
@browniebroke browniebroke deleted the feat/pagination branch January 17, 2022 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve how to deal with Pagination
1 participant