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

BaseSkill.schedule_repeating_event has wrong type annotation #128

Closed
Ramblurr opened this issue Aug 18, 2023 · 0 comments · Fixed by #183
Closed

BaseSkill.schedule_repeating_event has wrong type annotation #128

Ramblurr opened this issue Aug 18, 2023 · 0 comments · Fixed by #183
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Ramblurr
Copy link

def schedule_repeating_event(self, handler: callable,
when: Union[int, float, datetime.datetime],
frequency: Union[int, float],
data: Optional[dict] = None,
name: Optional[str] = None,
context: Optional[dict] = None):
"""
Schedule a repeating event.
Args:
handler: method to be called
when (datetime): time (in system timezone) for first
calling the handler, or None to
initially trigger <frequency> seconds
from now
frequency (float/int): time in seconds between calls
data (dict, optional): data to send when the handler is called
name (str, optional): reference name, must be unique
context (dict, optional): context (dict, optional): message
context to send when the handler
is called
"""
message = dig_for_message()
context = context or message.context if message else {}
context["skill_id"] = self.skill_id
self.event_scheduler.schedule_repeating_event(handler, when, frequency,

The type annotation for when should be Optional[Union[int, float, datetime.datetime]] because, as per the comment, it is valid to pass None to initially trigger frequency seconds from now

You get the type error:

Argument of type "None" cannot be assigned to parameter "when" of type "int | float | datetime" in function "schedule_repeating_event"
@ChanceNCounter ChanceNCounter added bug Something isn't working good first issue Good for newcomers labels Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants