-
Notifications
You must be signed in to change notification settings - Fork 116
Apply dict_type only to the dict cursor it was given to #930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0b236dd
2762664
b2ece22
2ee5fbc
e27e6e2
ee872f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,7 @@ def __init__( | |
| **kwargs, | ||
| ) | ||
| self._result_set_class = AthenaResultSet | ||
| self._result_set_kwargs: dict[str, Any] = {} | ||
|
|
||
| @property # type: ignore[explicit-override] # python/mypy#15900 | ||
| @override | ||
|
|
@@ -192,6 +193,7 @@ def execute( | |
| self.arraysize, | ||
| self._retry_config, | ||
| result_set_type_hints=options.result_set_type_hints, | ||
| **self._result_set_kwargs, | ||
| ) | ||
| else: | ||
| raise OperationalError(query_execution.state_change_reason) | ||
|
|
@@ -216,15 +218,15 @@ class DictCursor(Cursor): | |
| ... print(f"Product {row['id']}: {row['name']} - ${row['price']}") | ||
| """ | ||
|
|
||
| def __init__(self, **kwargs) -> None: | ||
| def __init__(self, dict_type: type[Any] | None = None, **kwargs) -> None: | ||
| """Initialize a DictCursor. | ||
|
|
||
| Args: | ||
| **kwargs: Arguments forwarded to ``Cursor.__init__``. If they include | ||
| ``dict_type``, it is also assigned to the class attribute | ||
| ``AthenaDictResultSet.dict_type``, the type used to build each row. | ||
| dict_type: The type used to build each row of this cursor's result | ||
| sets. If None, the result set class's ``dict_type`` is used. | ||
| **kwargs: Arguments forwarded to ``Cursor.__init__``. | ||
| """ | ||
| super().__init__(**kwargs) | ||
| self._result_set_class = AthenaDictResultSet | ||
| if "dict_type" in kwargs: | ||
| AthenaDictResultSet.dict_type = kwargs["dict_type"] | ||
| if dict_type is not None: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Self-review round one (implementation behavior), rewrite — FINDINGS, repaired The maintainer replaced the per-cursor subclass / Covered:
Finding (introduced, repaired in |
||
| self._result_set_kwargs = {"dict_type": dict_type} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -818,6 +818,19 @@ class AthenaDictResultSet(AthenaResultSet): | |
| # You can override this to use OrderedDict or other dict-like types. | ||
| dict_type: type[Any] = dict | ||
|
|
||
| def __init__(self, *args: Any, dict_type: type[Any] | None = None, **kwargs: Any) -> None: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Self-review round two (claims, callers, operations), rewrite — FINDINGS, PR description corrected Scope: base Claims checked:
Findings (PR description, corrected):
Independent review of this revision is next. |
||
| """Initialize the result set with an optional row type for this instance. | ||
|
|
||
| Args: | ||
| *args: Positional arguments passed to the next ``__init__`` in the MRO. | ||
| dict_type: The type used to build each row of this result set. If | ||
| None, the class attribute ``dict_type`` is used. | ||
| **kwargs: Keyword arguments passed to the next ``__init__`` in the MRO. | ||
| """ | ||
| if dict_type is not None: | ||
| self.dict_type = dict_type | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| @override | ||
| def _get_rows( | ||
| self, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Independent review (relayed), rewrite — CLEAN
Reviewer: Codex CLI 0.160.0, model
gpt-6-astra, reasoning effortmax, sandboxread-only,--ephemeral, session01a0fff0-6833-72c2-a3c5-6e9e897e0f6e. Static review only (no builds, tests, mypy or network). Scope: full range merge-base6be315ec4c87758f993778b0b2167696e848390a.. headee872f7a91da39ff2e60969718c57366a723ee6ein a detached snapshot without.env; the prompt carried the diff and intended behavior, not the PR number, description, commits or earlier findings. Snapshot and PR worktree verified unchanged after the run.Reviewer output (verbatim)
Surfaces covered:
execute, thread-pool_collect_result_set(includingdescription), asynciocreate, repeated execution, and pagination._result_set_classand_result_set_kwargs, direct constructor arguments, connectioncursor_kwargsprecedence, anddict_type=None.AthenaAioDictResultSet’s MRO; row type assignment occurs before synchronous or asynchronous pre-fetch.CLEAN
No actionable regression identified in the supplied range. Builds, tests, and mypy were not run; no network access was used. The checkout remains clean at the requested head.
Author note: the reviewer's observation that
test_dict_type_custom_result_setwould also pass on the original code is correct (the shared class attribute reached the subclass there); it guards the subclass path of the new argument passing, whiletest_dict_typeis the regression test for #923.