Skip to content

Commit e2b6fa8

Browse files
committed
Use obj reference target instead of data for typing objects
1 parent 88294fe commit e2b6fa8

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

discord/ext/commands/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ def __init__(self, missing_permissions: List[str], *args: Any) -> None:
870870

871871

872872
class BadUnionArgument(UserInputError):
873-
"""Exception raised when a :data:`typing.Union` converter fails for all
873+
"""Exception raised when a :obj:`typing.Union` converter fails for all
874874
its associated types.
875875
876876
This inherits from :exc:`UserInputError`

docs/ext/commands/commands.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ commands in an easy to use manner.
485485
typing.Union
486486
^^^^^^^^^^^^^^
487487

488-
A :data:`typing.Union` is a special type hint that allows for the command to take in any of the specific types instead of
488+
A :obj:`typing.Union` is a special type hint that allows for the command to take in any of the specific types instead of
489489
a singular type. For example, given the following:
490490

491491
.. code-block:: python3
@@ -502,12 +502,12 @@ The way this works is through a left-to-right order. It first attempts to conver
502502
:class:`discord.TextChannel`, and if it fails it tries to convert it to a :class:`discord.Member`. If all converters fail,
503503
then a special error is raised, :exc:`~ext.commands.BadUnionArgument`.
504504

505-
Note that any valid converter discussed above can be passed in to the argument list of a :data:`typing.Union`.
505+
Note that any valid converter discussed above can be passed in to the argument list of a :obj:`typing.Union`.
506506

507507
typing.Optional
508508
^^^^^^^^^^^^^^^^^
509509

510-
A :data:`typing.Optional` is a special type hint that allows for "back-referencing" behaviour. If the converter fails to
510+
A :obj:`typing.Optional` is a special type hint that allows for "back-referencing" behaviour. If the converter fails to
511511
parse into the specified type, the parser will skip the parameter and then either ``None`` or the specified default will be
512512
passed into the parameter instead. The parser will then continue on to the next parameters and converters, if any.
513513

@@ -536,7 +536,7 @@ typing.Literal
536536

537537
.. versionadded:: 2.0
538538

539-
A :data:`typing.Literal` is a special type hint that requires the passed parameter to be equal to one of the listed values
539+
A :obj:`typing.Literal` is a special type hint that requires the passed parameter to be equal to one of the listed values
540540
after being converted to the same type. For example, given the following:
541541

542542
.. code-block:: python3
@@ -550,7 +550,7 @@ after being converted to the same type. For example, given the following:
550550
551551
The ``buy_sell`` parameter must be either the literal string ``"buy"`` or ``"sell"`` and ``amount`` must convert to the
552552
``int`` ``1`` or ``2``. If ``buy_sell`` or ``amount`` don't match any value, then a special error is raised,
553-
:exc:`~.ext.commands.BadLiteralArgument`. Any literal values can be mixed and matched within the same :data:`typing.Literal` converter.
553+
:exc:`~.ext.commands.BadLiteralArgument`. Any literal values can be mixed and matched within the same :obj:`typing.Literal` converter.
554554

555555
Note that ``typing.Literal[True]`` and ``typing.Literal[False]`` still follow the :class:`bool` converter rules.
556556

@@ -559,7 +559,7 @@ typing.Annotated
559559

560560
.. versionadded:: 2.0
561561

562-
A :data:`typing.Annotated` is a special type introduced in Python 3.9 that allows the type checker to see one type, but allows the library to see another type. This is useful for appeasing the type checker for complicated converters. The second parameter of ``Annotated`` must be the converter that the library should use.
562+
A :obj:`typing.Annotated` is a special type introduced in Python 3.9 that allows the type checker to see one type, but allows the library to see another type. This is useful for appeasing the type checker for complicated converters. The second parameter of ``Annotated`` must be the converter that the library should use.
563563

564564
For example, given the following:
565565

@@ -581,7 +581,7 @@ The type checker will see ``arg`` as a regular :class:`str` but the library will
581581
Greedy
582582
^^^^^^^^
583583

584-
The :class:`~ext.commands.Greedy` converter is a generalisation of the :data:`typing.Optional` converter, except applied
584+
The :class:`~ext.commands.Greedy` converter is a generalisation of the :obj:`typing.Optional` converter, except applied
585585
to a list of arguments. In simple terms, this means that it tries to convert as much as it can until it can't convert
586586
any further.
587587

@@ -606,7 +606,7 @@ The type passed when using this converter depends on the parameter type that it
606606

607607
:class:`~ext.commands.Greedy` parameters can also be made optional by specifying an optional value.
608608

609-
When mixed with the :data:`typing.Optional` converter you can provide simple and expressive command invocation syntaxes:
609+
When mixed with the :obj:`typing.Optional` converter you can provide simple and expressive command invocation syntaxes:
610610

611611
.. code-block:: python3
612612
@@ -632,16 +632,16 @@ This command can be invoked any of the following ways:
632632
633633
.. warning::
634634

635-
The usage of :class:`~ext.commands.Greedy` and :data:`typing.Optional` are powerful and useful, however as a
635+
The usage of :class:`~ext.commands.Greedy` and :obj:`typing.Optional` are powerful and useful, however as a
636636
price, they open you up to some parsing ambiguities that might surprise some people.
637637

638-
For example, a signature expecting a :data:`typing.Optional` of a :class:`discord.Member` followed by a
638+
For example, a signature expecting a :obj:`typing.Optional` of a :class:`discord.Member` followed by a
639639
:class:`int` could catch a member named after a number due to the different ways a
640640
:class:`~ext.commands.MemberConverter` decides to fetch members. You should take care to not introduce
641641
unintended parsing ambiguities in your code. One technique would be to clamp down the expected syntaxes
642642
allowed through custom converters or reordering the parameters to minimise clashes.
643643

644-
To help aid with some parsing ambiguities, :class:`str`, ``None``, :data:`typing.Optional` and
644+
To help aid with some parsing ambiguities, :class:`str`, ``None``, :obj:`typing.Optional` and
645645
:class:`~ext.commands.Greedy` are forbidden as parameters for the :class:`~ext.commands.Greedy` converter.
646646

647647

@@ -663,7 +663,7 @@ Consider the following example:
663663
await ctx.send(f'You have uploaded <{attachment.url}>')
664664
665665
666-
When this command is invoked, the user must directly upload a file for the command body to be executed. When combined with the :data:`typing.Optional` converter, the user does not have to provide an attachment.
666+
When this command is invoked, the user must directly upload a file for the command body to be executed. When combined with the :obj:`typing.Optional` converter, the user does not have to provide an attachment.
667667

668668
.. code-block:: python3
669669
@@ -809,7 +809,7 @@ In order to customise the flag syntax we also have a few options that can be pas
809809
topic: Optional[str]
810810
nsfw: Optional[bool]
811811
slowmode: Optional[int]
812-
812+
813813
# Hello there --bold True
814814
class Greeting(commands.FlagConverter):
815815
text: str = commands.flag(positional=True)

0 commit comments

Comments
 (0)