You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ext/commands/commands.rst
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -485,7 +485,7 @@ commands in an easy to use manner.
485
485
typing.Union
486
486
^^^^^^^^^^^^^^
487
487
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
489
489
a singular type. For example, given the following:
490
490
491
491
.. code-block:: python3
@@ -502,12 +502,12 @@ The way this works is through a left-to-right order. It first attempts to conver
502
502
:class:`discord.TextChannel`, and if it fails it tries to convert it to a :class:`discord.Member`. If all converters fail,
503
503
then a special error is raised, :exc:`~ext.commands.BadUnionArgument`.
504
504
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`.
506
506
507
507
typing.Optional
508
508
^^^^^^^^^^^^^^^^^
509
509
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
511
511
parse into the specified type, the parser will skip the parameter and then either ``None`` or the specified default will be
512
512
passed into the parameter instead. The parser will then continue on to the next parameters and converters, if any.
513
513
@@ -536,7 +536,7 @@ typing.Literal
536
536
537
537
.. versionadded:: 2.0
538
538
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
540
540
after being converted to the same type. For example, given the following:
541
541
542
542
.. code-block:: python3
@@ -550,7 +550,7 @@ after being converted to the same type. For example, given the following:
550
550
551
551
The ``buy_sell`` parameter must be either the literal string ``"buy"`` or ``"sell"`` and ``amount`` must convert to the
552
552
``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.
554
554
555
555
Note that ``typing.Literal[True]`` and ``typing.Literal[False]`` still follow the :class:`bool` converter rules.
556
556
@@ -559,7 +559,7 @@ typing.Annotated
559
559
560
560
.. versionadded:: 2.0
561
561
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.
563
563
564
564
For example, given the following:
565
565
@@ -581,7 +581,7 @@ The type checker will see ``arg`` as a regular :class:`str` but the library will
581
581
Greedy
582
582
^^^^^^^^
583
583
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
585
585
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
586
586
any further.
587
587
@@ -606,7 +606,7 @@ The type passed when using this converter depends on the parameter type that it
606
606
607
607
:class:`~ext.commands.Greedy` parameters can also be made optional by specifying an optional value.
608
608
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:
610
610
611
611
.. code-block:: python3
612
612
@@ -632,16 +632,16 @@ This command can be invoked any of the following ways:
632
632
633
633
.. warning::
634
634
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
636
636
price, they open you up to some parsing ambiguities that might surprise some people.
637
637
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
639
639
:class:`int` could catch a member named after a number due to the different ways a
640
640
:class:`~ext.commands.MemberConverter` decides to fetch members. You should take care to not introduce
641
641
unintended parsing ambiguities in your code. One technique would be to clamp down the expected syntaxes
642
642
allowed through custom converters or reordering the parameters to minimise clashes.
643
643
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
645
645
:class:`~ext.commands.Greedy` are forbidden as parameters for the :class:`~ext.commands.Greedy` converter.
646
646
647
647
@@ -663,7 +663,7 @@ Consider the following example:
663
663
await ctx.send(f'You have uploaded <{attachment.url}>')
664
664
665
665
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.
667
667
668
668
.. code-block:: python3
669
669
@@ -809,7 +809,7 @@ In order to customise the flag syntax we also have a few options that can be pas
0 commit comments