-
Notifications
You must be signed in to change notification settings - Fork 35
Replace pendulum with whenever #5820
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
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 |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ | |
| from neo4j.graph import Node as Neo4jNode | ||
| from neo4j.graph import Path as Neo4jPath | ||
| from neo4j.graph import Relationship as Neo4jRelationship | ||
| from pendulum import Interval | ||
| from whenever import TimeDelta | ||
|
|
||
| from infrahub.graphql.initialization import GraphqlContext | ||
|
|
||
|
|
@@ -417,8 +417,8 @@ def __hash__(self) -> int: | |
| return hash(self.uuid) | ||
|
|
||
| @property | ||
| def time_range(self) -> Interval: | ||
| return self.to_time.obj - self.from_time.obj | ||
| def time_range(self) -> TimeDelta: | ||
| return self.to_time.get_obj() - self.from_time.get_obj() | ||
|
|
||
| def update_metadata( | ||
| self, | ||
|
|
@@ -447,8 +447,8 @@ def __hash__(self) -> int: | |
| return hash(self.uuid) | ||
|
|
||
| @property | ||
| def time_range(self) -> Interval: | ||
| return self.to_time.obj - self.from_time.obj | ||
| def time_range(self) -> TimeDelta: | ||
|
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. As per the updates in the SDK the time_range here and on line 420 will raise a deprecation warning due to us keeping the code in the function intact. return self.to_time.obj - self.from_time.objWe don't want to use return self.to_time - self.from_timeThere 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. Good catch, I fixed it |
||
| return self.to_time.get_obj() - self.from_time.get_obj() | ||
|
|
||
| def get_nodes_without_parents(self) -> set[EnrichedDiffNode]: | ||
| nodes_with_parent_uuids = set() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,12 +5,12 @@ | |
| from infrahub_sdk.timestamp import Timestamp as BaseTimestamp | ||
|
|
||
| if TYPE_CHECKING: | ||
| from pendulum.datetime import DateTime | ||
| from datetime import datetime | ||
|
|
||
|
|
||
| class Timestamp(BaseTimestamp): | ||
| async def to_graphql(self, *args: Any, **kwargs: Any) -> DateTime: # noqa: ARG002 | ||
| return self.obj | ||
| async def to_graphql(self, *args: Any, **kwargs: Any) -> datetime: # noqa: ARG002 | ||
| return self.to_datetime() | ||
|
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. Is this method used anywhere? 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. Yes |
||
|
|
||
| def get_query_filter_path(self, rel_name: str = "r") -> tuple[str, dict]: | ||
| """ | ||
|
|
||
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.
It would be nice to get rid of this import as well, if we can map it to a TimeDelta from our own TimeStamp class.
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.
agreed but it sounds like a bigger effort