Skip to content

Update rrule.pyi#3274

Merged
srittau merged 1 commit intopython:masterfrom
glyph:patch-1
Oct 4, 2019
Merged

Update rrule.pyi#3274
srittau merged 1 commit intopython:masterfrom
glyph:patch-1

Conversation

@glyph
Copy link
Contributor

@glyph glyph commented Sep 27, 2019

rrule.weekday(...) returns new rrule.weekday objects, not _common.weekday.

@glyph
Copy link
Contributor Author

glyph commented Sep 27, 2019

(Effectively a follow-up from #3154 :))

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thank you. Per the implementation __call__ should actually be defined on dateutil._common.weekday and use a type variable:

    def __call__(self: Type[_T], n: int) -> _T: ...

This way all sub-classes get the correct type.

@glyph
Copy link
Contributor Author

glyph commented Oct 1, 2019

Thanks @srittau - will update.

def __init__(self, weekday: int, n: Optional[int] = ...) -> None: ...

def __call__(self, n: int) -> weekday: ...
def __call__(self: Type[_T], n: int) -> _T: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, that was an error on my part. The Type is nonsense. It's just self: _T as self has the same type as the return value. Thatswhy the tests fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries. Should have caught it locally :-P. Let me try again…

@srittau srittau merged commit 8358984 into python:master Oct 4, 2019
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