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

refactor times.py #368

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft

Conversation

rishitc
Copy link

@rishitc rishitc commented Oct 19, 2024

Resolves #359

Copy link

semanticdiff-com bot commented Oct 19, 2024

Review changes with SemanticDiff.

Analyzed 1 of 1 files.

Overall, the semantic diff is 1% smaller than the GitHub diff.

Filename Status
✔️ fastkml/times.py 0.82% smaller

@pep8speaks
Copy link

pep8speaks commented Oct 19, 2024

Hello @rishitc! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-10-19 16:59:02 UTC

Copy link

what-the-diff bot commented Oct 19, 2024

PR Summary

  • Added Forward Declarations For Type Hints
    The introduction of from __future__ import annotations is a mechanism to tell the system that some information, specifically related to data types, will be provided later. It's like telling a story but saving some details for later parts.

  • Introduced a New Optional Parameter to a Class Constructor
    A new optional parameter when was incorporated to the constructor of a class. This looks to be a way to handle timeline references that you can choose to supply or ignore depending on your needs.

  • Simplified TimeStamp Class
    The TimeStamp class has been made simpler by removing two methods: etree_element and _get_kwargs. This might make the class easier to work with and modify in the future.

  • Added Three New Time-Related Classes
    There are three new classes: When, Begin, and End, all derived from _TimePrimitive. The role of these classes is to handle different aspects of time, enhancing our system's time management capabilities.

  • Streamlining TimeSpan Class
    Few methods that were previously dealing with the XML representation of time elements (begin, end, etc.) in the TimeSpan class were removed. This might have been done to make this class more focused and manageable.

Copy link

Preparing review...

1 similar comment
Copy link

Preparing review...

Copy link

Preparing review...

@@ -196,6 +199,7 @@ def __init__(
**kwargs,
)
self.timestamp = timestamp
self.when = when
Copy link
Owner

Choose a reason for hiding this comment

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

when and timestamp should be mutually exclusive

Copy link
Author

Choose a reason for hiding this comment

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

Hi @cleder,
Would you suggest I instead accept a parameter called pointInTime (I'm open to an alternate name), which is of type KmlDateTime | When so that users can only provide either a value of type When or KmlDateTime but not both?

@@ -206,6 +210,7 @@ def __repr__(self) -> str:
f"id={self.id!r}, "
f"target_id={self.target_id!r}, "
f"timestamp={self.timestamp!r}, "
f"when={self.when!r}, "
Copy link
Owner

Choose a reason for hiding this comment

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

There is no need to add both when and timestamp, as the when object can have more attributes like id and targetId it will be better to return just this.

----
precision (Optional[int]): The precision of the time values.
verbosity (Verbosity): The verbosity level for the element.
class When(_TimePrimitive):
Copy link
Owner

@cleder cleder Oct 20, 2024

Choose a reason for hiding this comment

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

I think When, Begin and End should inherit from _BaseObject not _TimePrimitive

Copy link
Author

Choose a reason for hiding this comment

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

This should be fine as _BaseObject is higher in the inheritance hierarchy while still having access to the class methods etree_element and _get_kwargs defined in the base class _XMLObject.

  • These two class methods will be needed to implement the When, Begin and End classes.

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.

Refactor times.py
3 participants