-
Notifications
You must be signed in to change notification settings - Fork 287
-
Hand-waving, I have this:
class MockDateTime: @overload @classmethod def set( cls, year: int, month: int, day: int, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: TZInfo = ..., ) -> None: ... @overload @classmethod def set( cls, instance: datetime, / ) -> None: ... @classmethod def set(cls, *args: int | datetime, **kw: int) -> None: """ This will set the :class:`datetime.datetime` created from the supplied parameters as the next datetime to be returned by :meth:`~MockDateTime.now` or :meth:`~MockDateTime.utcnow`, clearing out any datetimes in the queue. An instance of :class:`~datetime.datetime` may also be passed as a single positional argument. """
So, those ellipsis make mypy unhappy, but how do I express "these may not be present, but if they are, they must be ints, or TZInfo in the case of tzinfo"?
Note, this is explicitly not what I want, since it's not valid to pass None for these:
class MockDateTime: @overload @classmethod def set( cls, year: int, month: int, day: int, hour: int = None, minute: int = None, second: int = None, microsecond: int = None, tzinfo: TZInfo = None, ) -> None: ...
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
See #2040 for newer discussion on this.
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment