Revert required optional fields on read/response data classes (DM-3585)#2490
Conversation
6c87eb5 to
861957f
Compare
Summary of ChangesHello, 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 refines the data class definitions throughout the SDK to better reflect the optionality of fields returned by the API. By making many constructor parameters optional, the SDK becomes more resilient to partial API responses and provides clearer guidance on truly required fields for resource creation. This change also includes specific adjustments to enforce required fields where data integrity is paramount and updates type hints for improved precision. The overall impact is a more robust and type-safe SDK experience. 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
Activity
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
|
861957f to
2aa1610
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a number of changes across various data classes, primarily to align their definitions with the API responses by making some fields optional and others required. This is a valuable cleanup that improves type safety and robustness. The changes are extensive but appear to be consistent and well-tested. I've identified one critical issue regarding a type hint in the Datapoints class that should be addressed.
| timezone: datetime.timezone | ZoneInfo | None = None, | ||
| ) -> None: | ||
| self.id = id | ||
| self.id: int = id # type: ignore [assignment] |
There was a problem hiding this comment.
The type hint for self.id is int, but the assigned value id can be None (as per the __init__ signature id: int | None = None). This creates a discrepancy between the static type and the possible runtime type, which can lead to TypeError exceptions in code that relies on this type hint. The type hint for self.id should be int | None to accurately reflect its possible values. If the intention is to deprecate None for id, consider issuing a warnings.warn when id is None instead of using type: ignore.
| self.id: int = id # type: ignore [assignment] | |
| self.id: int | None = id | |
There was a problem hiding this comment.
Yeah yeah yeah, this is on purpose my love
e52e552 to
a61622a
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## pysdk-release-v8 #2490 +/- ##
====================================================
- Coverage 64.59% 64.59% -0.01%
====================================================
Files 467 467
Lines 47789 47729 -60
====================================================
- Hits 30871 30832 -39
+ Misses 16918 16897 -21
🚀 New features to boost your workflow:
|
|
Great work! I'm sure this was a lot fun to do 😄 |
a61622a to
f95e69a
Compare
See slack thread for info: https://cognitedata.slack.com/archives/C082WRQ5HSL/p1771577763338209
Partially reverts some of the changes in 8k LOC PR: #2311 😓
https://cognitedata.atlassian.net/browse/DM-3585