Skip to content

Commit 0cde841

Browse files
authored
Clarify guidance in the "function and method signatures" section
The type annotations part was a little outdated. For the positional and keyword-only descriptions, improve the language to account for exceptions to the default design rules. Closes: #475 PR-URL: #730 Reviewed-by: Athan Reines <[email protected]>
1 parent 6e320d0 commit 0cde841

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: spec/draft/API_specification/function_and_method_signatures.rst

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Function and method signatures
55

66
Function signatures in this standard adhere to the following:
77

8-
1. Positional parameters must be `positional-only <https://www.python.org/dev/peps/pep-0570/>`_ parameters.
8+
1. Positional parameters should be `positional-only <https://www.python.org/dev/peps/pep-0570/>`_ parameters.
99
Positional-only parameters have no externally-usable name. When a function
1010
accepting positional-only parameters is called, positional arguments are
1111
mapped to these parameters based solely on their order.
@@ -20,7 +20,7 @@ Function signatures in this standard adhere to the following:
2020
namespace >= 3.8. Alternatively, they can add guidance to their users in the
2121
documentation to use the functions as if they were positional-only.
2222

23-
2. Optional parameters must be `keyword-only <https://www.python.org/dev/peps/pep-3102/>`_ arguments.
23+
2. Optional parameters should be `keyword-only <https://www.python.org/dev/peps/pep-3102/>`_ arguments.
2424

2525
*Rationale: this leads to more readable code, and it makes it easier to
2626
evolve an API over time by adding keywords without having to worry about
@@ -30,8 +30,8 @@ Function signatures in this standard adhere to the following:
3030
is called ``x``. For functions that have multiple array parameters, those
3131
parameters are called ``xi`` with ``i = 1, 2, ...`` (i.e., ``x1``, ``x2``).
3232

33-
4. Type annotations are left out of the signatures themselves for readability; however,
34-
they are added to individual parameter descriptions. For code which aims to
33+
4. Signatures include type annotations. The type annotations are also added to
34+
individual parameter and return value descriptions. For code which aims to
3535
adhere to the standard, adding type annotations is strongly recommended.
3636

3737
A function signature and description will look like:
@@ -57,3 +57,7 @@ A function signature and description will look like:
5757

5858

5959
Method signatures will follow the same conventions modulo the addition of ``self``.
60+
61+
Note that there are a few exceptions to rules (1) and (2), in cases where
62+
it enhances readability or use of the non-default form of the parameter in
63+
question is commonly used in code written for existing array libraries.

0 commit comments

Comments
 (0)