Update v8 with the latest commits from v7#2478
Conversation
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…y method (#2465) Co-authored-by: Håkon V. Treider <haakonvt@gmail.com>
Summary of ChangesHello @haakonvt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request synchronizes the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces timezone support for synthetic time series queries, along with updates to documentation dependencies and configurations. The changes are generally good, but I've identified a regression in the type hints for the query method in both the synchronous and asynchronous APIs. The updated overloads no longer account for sympy expressions, which reduces type safety. I've provided suggestions to correct the overloads to include sympy.Basic types, aligning them with the implementation's capabilities and adhering to the project's strong typing principles.
| @overload | ||
| async def query( | ||
| self, | ||
| expressions: SequenceNotStr[str] | SequenceNotStr[sympy.Basic], | ||
| start: int | str | datetime, | ||
| end: int | str | datetime, | ||
| expressions: str, | ||
| start: int | str | datetime.datetime, | ||
| end: int | str | datetime.datetime, | ||
| limit: int | None = None, | ||
| variables: Mapping[str | sympy.Symbol, str | NodeId | TimeSeries | TimeSeriesWrite] | None = None, | ||
| aggregate: str | None = None, | ||
| granularity: str | None = None, | ||
| target_unit: str | None = None, | ||
| target_unit_system: str | None = None, | ||
| ) -> DatapointsList: ... | ||
| timezone: str | datetime.timezone | ZoneInfo | None = None, | ||
| ) -> Datapoints: ... | ||
|
|
||
| @overload | ||
| async def query( | ||
| self, | ||
| expressions: str | sympy.Basic, | ||
| start: int | str | datetime, | ||
| end: int | str | datetime, | ||
| expressions: SequenceNotStr[str], | ||
| start: int | str | datetime.datetime, | ||
| end: int | str | datetime.datetime, | ||
| limit: int | None = None, | ||
| variables: Mapping[str | sympy.Symbol, str | NodeId | TimeSeries | TimeSeriesWrite] | None = None, | ||
| aggregate: str | None = None, | ||
| granularity: str | None = None, | ||
| target_unit: str | None = None, | ||
| target_unit_system: str | None = None, | ||
| ) -> Datapoints: ... | ||
| timezone: str | datetime.timezone | ZoneInfo | None = None, | ||
| ) -> DatapointsList: ... |
There was a problem hiding this comment.
The updated query method overloads are missing support for sympy.Basic expressions. This is a regression in type hinting, as the implementation still supports sympy expressions. The overloads should be updated to reflect all supported types to ensure type safety and provide a better developer experience.
@overload
async def query(
self,
expressions: str | sympy.Basic,
start: int | str | datetime.datetime,
end: int | str | datetime.datetime,
limit: int | None = None,
variables: Mapping[str | sympy.Symbol, str | NodeId | TimeSeries | TimeSeriesWrite] | None = None,
aggregate: str | None = None,
granularity: str | None = None,
target_unit: str | None = None,
target_unit_system: str | None = None,
timezone: str | datetime.timezone | ZoneInfo | None = None,
) -> Datapoints: ...
@overload
async def query(
self,
expressions: SequenceNotStr[str | sympy.Basic],
start: int | str | datetime.datetime,
end: int | str | datetime.datetime,
limit: int | None = None,
variables: Mapping[str | sympy.Symbol, str | NodeId | TimeSeries | TimeSeriesWrite] | None = None,
aggregate: str | None = None,
granularity: str | None = None,
target_unit: str | None = None,
target_unit_system: str | None = None,
timezone: str | datetime.timezone | ZoneInfo | None = None,
) -> DatapointsList: ...References
- The style guide requires strong typing and that all functions, methods, and class attributes must have type hints. The current overloads are incomplete and do not cover all supported input types for the 'expressions' parameter. (link)
There was a problem hiding this comment.
@gemini-code-assist Because sympy.Basic resolves to Any in mypy (due to ignore_missing_imports = true in mypy.ini).
So str | sympy.Basic becomes str | Any = Any, which matches everything, including e.g. list[str]. This causes the first overload to always match, making the second overload unreachable.
The implementation still works at runtime; it's only the type hints that can't distinguish the overloads when sympy types are involved.
There was a problem hiding this comment.
Thank you for the detailed explanation, haakonvt. I understand the issue now. You are correct that including sympy.Basic in the overloads, given mypy's ignore_missing_imports = true and its resolution of sympy.Basic to Any, would indeed make the first overload str | Any effectively Any, thus rendering subsequent overloads unreachable.
Given this constraint with mypy, your current approach of omitting sympy.Basic from the overloads and only including it in the implementation signature is a pragmatic solution to ensure correct overload resolution by the type checker, while still supporting sympy.Basic at runtime. The runtime behavior remains correct, and the type hints are as precise as possible under the circumstances.
This is a valid workaround for the type checking limitation.
9ba8d1d to
197af53
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## pysdk-release-v8 #2478 +/- ##
====================================================
+ Coverage 64.54% 64.59% +0.05%
====================================================
Files 467 467
Lines 47774 47789 +15
====================================================
+ Hits 30836 30871 +35
+ Misses 16938 16918 -20
🚀 New features to boost your workflow:
|
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…task now uses actual function (#2475) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
4f3374c to
d16b196
Compare
d16b196 to
b268276
Compare
|
🦄 |
No description provided.