Skip to content
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: instance type not possible to reset to null #1970

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

haakonvt
Copy link
Contributor

@haakonvt haakonvt commented Oct 10, 2024

@haakonvt haakonvt requested review from a team as code owners October 10, 2024 08:18
Copy link
Collaborator

@erlendvollset erlendvollset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edge.type cannot be set to null - it is non-nullable. So if omitted it should not be passed as null. I'm also not certain we'll want omitted meaning explicit null for node base props either. This might require changes in DMS too to be handled properly. i.e. we need to differentiate between omitted and null for base properties, like we do for custom properties.

@haakonvt
Copy link
Contributor Author

edge.type cannot be set to null - it is non-nullable. So if omitted it should not be passed as null. I'm also not certain we'll want omitted meaning explicit null for node base props either. This might require changes in DMS too to be handled properly. i.e. we need to differentiate between omitted and null for base properties, like we do for custom properties.

oh right - I'll see what I can in the SDK as a workaround for now 👍

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.27%. Comparing base (48be4f4) to head (e7322cc).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1970   +/-   ##
=======================================
  Coverage   90.26%   90.27%           
=======================================
  Files         139      139           
  Lines       21735    21754   +19     
=======================================
+ Hits        19620    19638   +18     
- Misses       2115     2116    +1     
Files with missing lines Coverage Δ
cognite/client/_constants.py 86.66% <100.00%> (+0.95%) ⬆️
cognite/client/_version.py 100.00% <100.00%> (ø)
...ognite/client/data_classes/data_modeling/cdm/v1.py 60.98% <100.00%> (+0.03%) ⬆️
...ite/client/data_classes/data_modeling/instances.py 91.18% <100.00%> (+0.20%) ⬆️
cognite/client/data_classes/datapoints.py 92.53% <100.00%> (-0.02%) ⬇️

... and 1 file with indirect coverage changes

@@ -87,7 +88,7 @@ def __init__(
station_360: DirectRelationReference | tuple[str, str] | None = None,
taken_at: datetime | None = None,
existing_version: int | None = None,
type: DirectRelationReference | tuple[str, str] | None = None,
type: DirectRelationReference | tuple[str, str] | None = NOT_SET, # type: ignore [assignment]
Copy link
Collaborator

@erlendvollset erlendvollset Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, NOT_SET should be an instance of a NotSet class (or I prefer OMITTED/Omitted), and then we do this instead:

Suggested change
type: DirectRelationReference | tuple[str, str] | None = NOT_SET, # type: ignore [assignment]
type: DirectRelationReference | tuple[str, str] | Omitted | None = OMITTED,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While class Omitted with a (singleton instance) OMITTED is nicer for sure! ...I don't really like to expose this to the users (more than necessary, the default value).

It exposes internal details; users will see Omitted in the type annotation and perhaps wonder what it does, when in reality it is an implementation detail. This may lead to unnecessary confusion (do I need to know what this is/does?), which in turn may lead to unintended usage.

It also goes against the principle of what the type annotations mean; these are the allowed types you may pass. The point with the default value is when it is not passed.

@haakonvt
Copy link
Contributor Author

Blocked until DMS starts to distinguish between "not given" and "given as null"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants