Skip to content

Probable bug in DURATION getter #884

@jrd

Description

@jrd

if duration is not default and not isinstance(duration, timedelta):
raise InvalidCalendar(
f"DURATION must be a timedelta, not {type(duration).__name__}."
)
return None

While reading the source code I think I found a little error.

If the duration property exist (so it’s not default object) and it’s already a timedelta instance, then currently None is returned.

Maybe it should be something like that:

    if isinstance(duration, timedelta):  # it cannot be default as default is not a timedelta instance
        return duration
    elif duration is not default:
        raise InvalidCalendar(
            f"DURATION must be a timedelta, not {type(duration).__name__}."
        )
    return None

But maybe I didn’t understand the code correctly…

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions