Browse Source

Change snowflake_time and time_snowflake parameters to pos/kw-only

pull/8342/head
Rapptz 3 years ago
parent
commit
5b56899676
  1. 16
      discord/utils.py
  2. 9
      docs/migrating.rst

16
discord/utils.py

@ -354,8 +354,12 @@ def oauth_url(
return url
def snowflake_time(id: int) -> datetime.datetime:
"""
def snowflake_time(id: int, /) -> datetime.datetime:
"""Returns the creation time of the given snowflake.
.. versionchanged:: 2.0
The ``id`` parameter is now positional-only.
Parameters
-----------
id: :class:`int`
@ -370,14 +374,18 @@ def snowflake_time(id: int) -> datetime.datetime:
return datetime.datetime.fromtimestamp(timestamp, tz=datetime.timezone.utc)
def time_snowflake(dt: datetime.datetime, high: bool = False) -> int:
def time_snowflake(dt: datetime.datetime, /, *, high: bool = False) -> int:
"""Returns a numeric snowflake pretending to be created at the given date.
When using as the lower end of a range, use ``time_snowflake(high=False) - 1``
to be inclusive, ``high=True`` to be exclusive.
When using as the higher end of a range, use ``time_snowflake(high=True) + 1``
to be inclusive, ``high=False`` to be exclusive
to be inclusive, ``high=False`` to be exclusive.
.. versionchanged:: 2.0
The ``high`` parameter is now keyword-only and the ``dt`` parameter is now
positional-only.
Parameters
-----------

9
docs/migrating.rst

@ -1038,19 +1038,22 @@ Parameters in the following methods are now all positional-only:
- :meth:`TextChannel.get_partial_message`
- :meth:`TextChannel.delete_messages`
- :meth:`Webhook.delete_message`
- :meth:`utils.find`
- :func:`utils.find`
- :func:`utils.snowflake_time`
The following parameters are now positional-only:
- ``iterable`` in :meth:`utils.get`
- ``iterable`` in :func:`utils.get`
- ``event_method`` in :meth:`Client.on_error`
- ``event`` in :meth:`Client.wait_for`
- ``dt`` in :func:`utils.time_snowflake`
The following are now keyword-only:
- Parameters in :meth:`Reaction.users`
- Parameters in :meth:`Client.create_guild`
- ``permissions``, ``guild``, ``redirect_uri``, and ``scopes`` parameters in :meth:`utils.oauth_url`
- ``permissions``, ``guild``, ``redirect_uri``, and ``scopes`` parameters in :func:`utils.oauth_url`
- ``high`` in :func:`utils.snowflake_time`
The library now less often uses ``None`` as the default value for function/method parameters.

Loading…
Cancel
Save