Describe the bug
PaginatedList hasn't been updated for the combine_kwargs method. It expects **kwargs being formatted as
PaginatedList(..., **kwargs) instead of PaginatedList(...,_kwargs=combine_kwargs(**kwargs)) or PaginatedList(..., kwargs=combine_kwargs(**kwargs)).
Some functions use _kwargs=.. and others use kwargs=.., but the requester method uses _kwargs as a input so I am guessing _kwargs should be used for all.
currently this is done
self._first_params = kwargs or {}
self._first_params["per_page"] = kwargs.get("per_page", 100)
where 100 is the default instead of the 10 mentioned in the documentation.
To Reproduce
import time
CANVAS_TOKEN = ...; API_URL = ...;
canvas = Canvas(CANVAS_TOKEN, API_URL)
start = time.perf_counter()
list(canvas.get_courses(per_page=1))
print(time.perf_counter() - start)
start2 = time.perf_counter()
list(canvas.get_courses(per_page=30))
print(time.perf_counter() - start2)
Expected behavior
one would take longer then the other, but they take the same since both have per_page set to 100.
kwargs will be {'_kwargs': [('per_page', 1)]} or {'_kwargs': [('per_page', 30)]}, but since per_page is not in it, the default is used and
self._first_params = {'_kwargs': [('per_page', 1)], 'per_page': 100}
Environment information
it is still in the latest version of the github repo,
Additional context
edit:
from the logging
2025-03-19 14:16:43,560 - canvasapi.requester - DEBUG - Data: [('per_page', 1), ('per_page', 100)]
which when converted to dictionary uses the last occurence so 100.
fix could be to remove self._first_params["per_page"] = kwargs.get("per_page", 100),
or insert it in the beginning of _kwargs such that it gets overrided when the user gives it.
Also documentation should be updated if this is the desired behaviour.
Describe the bug
PaginatedList hasn't been updated for the
combine_kwargsmethod. It expects**kwargsbeing formatted asPaginatedList(..., **kwargs)instead ofPaginatedList(...,_kwargs=combine_kwargs(**kwargs))orPaginatedList(..., kwargs=combine_kwargs(**kwargs)).Some functions use
_kwargs=..and others usekwargs=.., but the requester method uses_kwargsas a input so I am guessing_kwargsshould be used for all.currently this is done
where 100 is the default instead of the 10 mentioned in the documentation.
To Reproduce
Expected behavior
one would take longer then the other, but they take the same since both have per_page set to 100.
kwargswill be{'_kwargs': [('per_page', 1)]}or{'_kwargs': [('per_page', 30)]}, but sinceper_pageis not in it, the default is used andself._first_params = {'_kwargs': [('per_page', 1)], 'per_page': 100}Environment information
it is still in the latest version of the github repo,
Additional context
edit:
from the logging
2025-03-19 14:16:43,560 - canvasapi.requester - DEBUG - Data: [('per_page', 1), ('per_page', 100)]which when converted to dictionary uses the last occurence so 100.
fix could be to remove
self._first_params["per_page"] = kwargs.get("per_page", 100),or insert it in the beginning of
_kwargssuch that it gets overrided when the user gives it.Also documentation should be updated if this is the desired behaviour.