-
Notifications
You must be signed in to change notification settings - Fork 671
feat: emit a warning when using a list()
method returns max
#1875
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
Conversation
bc9471a
to
0cbddce
Compare
Codecov Report
@@ Coverage Diff @@
## main #1875 +/- ##
=======================================
Coverage 92.56% 92.57%
=======================================
Files 78 78
Lines 4910 4930 +20
=======================================
+ Hits 4545 4564 +19
- Misses 365 366 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
d6ef9fe
to
9d1e6e8
Compare
92da850
to
c790f8c
Compare
Example program using this:
Run of program:
|
0223989
to
63a6f1e
Compare
ec10a57
to
9aa7a66
Compare
fb933c5
to
1fc8aa8
Compare
1fc8aa8
to
9d7de47
Compare
3bd6d8d
to
439e50b
Compare
439e50b
to
0969cd8
Compare
f99cf74
to
ac15b21
Compare
Finally had a look around and here's some more valid use cases where we don't want to emit warnings on this - essentially whenever any kind of list filter is applied, I'd say. In those cases users mostly only care about the first item.
|
Answering without doing a lot of research on these:
Warning will not be issued unless for some reason 20 items are returned by the
Warning will not be issued unless for some reason 20 items are returned by the
Yes a warning has a good chance of being produced for this one. I have submitted a PR that adds a |
ac15b21
to
9117111
Compare
A common cause of issues filed and questions raised is that a user will call a `list()` method and only get 20 items. As this is the default maximum of items that will be returned from a `list()` method. To help with this we now emit a warning when the result from a `list()` method is greater-than or equal to 20 (or the specified `per_page` value) and the user is not using either `all=True`, `all=False`, `as_list=False`, or `page=X`.
9117111
to
1339d64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @JohnVillalovos! Took a while as I am really uneasy about eagerly sending warnings but this will definitely reduce the issues filed.
Thanks @nejch ! I'm interested to see feedback on it once it starts getting used by people. I know when I tried it on my code I found spots where I was like "whoops!". |
A common cause of issues filed and questions raised is that a user
will call a
list()
method and only get 20 items. As this is thedefault maximum of items that will be returned from a
list()
method.To help with this we now emit a warning when the result from a
list()
method is greater-than or equal to 20 (or the specifiedper_page
value) and the user is not using eitherall=True
,all=False
,as_list=False
, orpage=X
.