@@ -4274,9 +4274,9 @@ def query(
42744274 """Return items that satisfy the given query.
42754275 Query syntax should be in SuperAnnotate query language(https://doc.superannotate.com/docs/explore-overview).
42764276
4277- The returned object behaves like a list of dicts (supports iteration,
4278- indexing, and ``len()``) and additionally exposes a ``.count()`` method
4279- that returns the total number of matching items without fetching them .
4277+ The returned :class:`QueryResult` behaves like a list of dicts (supports
4278+ iteration, indexing, and ``len()``) and additionally exposes a
4279+ ``.count()`` method .
42804280
42814281 :param project: Accepts a project as a string ("project" or "project/folder") or as a tuple (project_id, folder_id), where the folder is optional.”
42824282 :type project: Union[str, int, Tuple[int, int], Tuple[str, str]]
@@ -4288,28 +4288,40 @@ def query(
42884288 To return all the items in the specified subset, set the value of query param to None.
42894289 :type subset: str
42904290
4291- :return: queried items' metadata list
4292- :rtype: list of dicts
4291+ :return: queried items' metadata list with a ``.count()`` method
4292+ :rtype: QueryResult ( list of dicts with .count() method)
42934293
42944294 Request Example:
42954295 ::
42964296
42974297 client = SAClient()
42984298
4299- # Iterate over queried items (fetches data)
43004299 queried_items = client.query(
43014300 project="Image Project",
43024301 query="instance(error = true)"
43034302 )
43044303 for item in queried_items:
43054304 print(item["name"])
43064305
4307- # Get only the count without fetching all items
4308- total = client.query(
4309- project="Image Project",
4310- query="instance(error = true)"
4311- ).count()
4312- print(f"Total matching items: {total}")
4306+ .. py:method:: query.count() -> int
4307+
4308+ Returns the total number of items matching the query without
4309+ fetching them. This is a lightweight call that does not trigger
4310+ pagination.
4311+
4312+ :return: total number of matching items
4313+ :rtype: int
4314+
4315+ Request Example:
4316+ ::
4317+
4318+ client = SAClient()
4319+
4320+ total = client.query(
4321+ project="Image Project",
4322+ query="instance(error = true)"
4323+ ).count()
4324+ print(f"Total matching items: {total}")
43134325 """
43144326 project_entity , folder = self .controller .get_project_folder (project )
43154327 fetch_entities = partial (
0 commit comments