Skip to content

Commit 688dc3f

Browse files
author
Vadim Grem
committed
refactor: check return_raw_content via isinstance + property
Replace getattr hack in _is_content_download with a proper isinstance + property check directly on the query object.
1 parent b5962dd commit 688dc3f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

office365/runtime/odata/request.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def process_response(self, response: Response, query: ClientQuery) -> None:
7979

8080
content_type = response.headers.get("Content-Type", "").lower().split(";")[0]
8181

82-
if content_type != "application/json" or self._is_content_download(query):
82+
if content_type != "application/json" or self._is_raw_content_query(query):
8383
if isinstance(return_type, ClientResult):
8484
return_type.set_property("__value", response.content)
8585
else:
@@ -90,9 +90,9 @@ def process_response(self, response: Response, query: ClientQuery) -> None:
9090
self.map_json(response.json(), return_type, json_format)
9191

9292
@staticmethod
93-
def _is_content_download(query: ClientQuery) -> bool:
94-
"""Check if the query is a raw content download (file content, not OData metadata)."""
95-
return bool(getattr(query, "return_raw_content", False))
93+
def _is_raw_content_query(query: ClientQuery) -> bool:
94+
"""Check if the query represents a raw content retrieval (e.g. file download)."""
95+
return isinstance(query, FunctionQuery) and query.return_raw_content
9696

9797
def map_json(
9898
self,

0 commit comments

Comments
 (0)