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

Update type annotation in get_finite_datetime_ranges_from_timestamps #37

Merged
merged 1 commit into from
Feb 5, 2023

Conversation

con-cat
Copy link
Member

@con-cat con-cat commented Feb 2, 2023

Before this change, the finite_datetime_range argument to this function had the type FiniteDatetimeRange.

The function doesn't use any of the methods from that class and works when called on objects of its parent type
FiniteRange[datetime.datetime], so this change updates the type annotation to reflect that.

This caused an issue for me when iterating through a FiniteRangeSet and calling this function - the following works, but mypy currently doesn't allow it:

range_set = FiniteRangeSet(
    [FiniteDatetimeRange(datetime.datetime(2023, 1, 1), datetime.datetime(2023, 1, 31))]
)
for datetime_range in range_set:
    get_finite_datetime_ranges_from_timestamps(datetime_range, [])

Gives this error:

error: Argument 1 to "get_finite_datetime_ranges_from_timestamps" has incompatible type "FiniteRange[datetime]"; expected "FiniteDatetimeRange"  [arg-type]

Before this change, the finite_datetime_range argument to this
function had the type FiniteDatetimeRange.

The function doesn't use any of the methods from that class and works
when called on objects of its parent type
FiniteRange[datetime.datetime], so this change updates the type
annotation to reflect that.
@con-cat con-cat merged commit dad4f9b into main Feb 5, 2023
@con-cat con-cat deleted the 230203-update-type-signature branch February 5, 2023 23:14
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.

3 participants