-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fix filter dump in Data Modeling #1510
Conversation
@@ -68,8 +68,20 @@ def _dump_property(property_: PropertyReference, camel_case: bool) -> list[str] | |||
class Filter(ABC): | |||
_filter_name: str | |||
|
|||
def dump(self, camel_case: bool = True) -> dict[str, Any]: | |||
return {self._filter_name: self._filter_body(camel_case)} | |||
def dump(self, camel_case_property: bool = False) -> dict[str, Any]: |
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.
This is the bug introduced in v7, the default was changed from False
to True
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1510 +/- ##
==========================================
+ Coverage 91.62% 91.64% +0.02%
==========================================
Files 120 120
Lines 15605 15607 +2
==========================================
+ Hits 14298 14303 +5
+ Misses 1307 1304 -3
|
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.
I like the change to camel_case_property
to make it distinct from other methods
@@ -193,7 +194,7 @@ def create_args(id_: Id) -> tuple[str, str, str | None, Literal["node", "edge"] | |||
return id_[0], id_[1], None, id_type # type: ignore[return-value] | |||
raise ValueError("Instance given as a tuple must have two elements (space, externalId)") | |||
if isinstance(id_, tuple): | |||
return id_[0], id_[1], id_[2] if len(id_) == 3 else None, None | |||
return id_[0], id_[1], (id_[2] if len(id_) == 3 else None), None |
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.
Not sure if this is more readable or not, you choose 😜
return id_[0], id_[1], (id_[2] if len(id_) == 3 else None), None | |
return (*id_, None, None)[:4] |
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.
Can we catch this in a test?
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.
(nvm i see it's already done 💯)
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.
@erlendvollset That change was only for easier readability (not referring to my suggestion but his added parens)
if instance.target is not None: | ||
instance.target = instance._convert_resource(instance.target, instance.target_type) # type: ignore | ||
instance.target = instance._convert_resource(instance.target, instance.target_type, cognite_client) # type: ignore |
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.
Nice catch!
@@ -63,18 +64,18 @@ def __iter__(self) -> Iterator[Space]: | |||
return self() | |||
|
|||
@overload | |||
def retrieve(self, spaces: str) -> Space | None: # type: ignore[overload-overlap] | |||
def retrieve(self, spaces: str) -> Space | None: |
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.
Oooh nice! ...to get overloads working 👌
Description
[7.0.3] - 2023-11-15
Fixed
cognite.client.data_classes.filter
used with anydata_modeling
endpoint raised aCogniteAPIError
forsnake_cased properties. This is now fixed.
Checklist:
If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.