When there is no link header sent, this signifies that this is the only
page of results. If data is empty, or only contains a list of items, we
should count them, but this can be defeated -- if the returned data
contains a total_count key, we should use it. This also uncovered a bug
in the test suite for searching topics.
Closes#960
This PR proposes adding two missing params to constructor in `.reversed`. This preserves the `headers` as well as the `list_item` once cloned.
Fixes#945.
This PR #596 seems stale, so I have opened up this one with the requested changes from @sfdye.
This is the code from @Tommos0's [comment][1] with some modification.
There are 2 tests failing. I think this is due to the change in the query string and the cached test data just needs to be refreshed for those tests.
[1]: https://github.com/PyGithub/PyGithub/pull/596#issuecomment-315013949
For /search resources the resulting JSON contains 'total_count' and
'items'. The latter is the list PaginatedList expects, so just
transparently use that list. Everything else works just like other
lists.
Also change __grow()'s visibility to allow PaginatedList to use it
in order to peek at 'total_count', making it available as a property.
Changed reversed(content) to content[::-1] in order to return
a real list and not a generator.
The code in PaginatedListBase.__grow does an iteration over
newElements when using `+=` and then returns them.
When using a generator, newElements would be empty when they are returned.
Fixes a bug introduced in the previous commits.
Now testing a case where no lastUrl is returned.
Also fixing a regression where nextUrl wasn't erased properly.
* if firstParams was None, PaginatedList was calling dict(None)
which fails with a TypeError. If firstParams is None, just use
an empty tuple, which dict() handles properly
This is a minor thing. It’s a convention, not a rule (obviously)—but it’s also a best practice.
Many text editors look for this kind of comment as the first line—or second line, if there is a shebang (the `#!/usr/bin/env python`, or whatever else)—and make use of this to determine the file’s encoding.