Skip to content

Commit d43fa58

Browse files
Abel Milashclaude
andcommitted
Move _operation_context init to _ODataBase to eliminate duplication
Both sync and async clients had identical 2-line initialization: ctx_obj = self.config.operation_context self._operation_context = ctx_obj.user_agent_context if ctx_obj else None Since self.config is already available in _ODataBase.__init__, this belongs in the base class. Subclasses inherit it and use it when building the User-Agent header. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2642493 commit d43fa58

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ def __init__(
8181
session=session,
8282
logger=self._http_logger,
8383
)
84-
ctx_obj = self.config.operation_context
85-
self._operation_context = ctx_obj.user_agent_context if ctx_obj else None
86-
8784
def close(self) -> None:
8885
"""Close the OData client and release resources.
8986

src/PowerPlatform/Dataverse/data/_odata_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def __init__(self, base_url: str, config=None) -> None:
142142
self._logical_primaryid_cache: dict[str, str] = {}
143143
self._picklist_label_cache: dict[str, dict] = {}
144144
self._picklist_cache_ttl_seconds = 3600 # 1 hour TTL
145+
ctx_obj = self.config.operation_context
146+
self._operation_context: Optional[str] = ctx_obj.user_agent_context if ctx_obj else None
145147
self._http_logger = None
146148
if self.config.log_config is not None:
147149
from ..core._http_logger import _HttpLogger

0 commit comments

Comments
 (0)