@@ -5,7 +5,7 @@ Function and method signatures
5
5
6
6
Function signatures in this standard adhere to the following:
7
7
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.
9
9
Positional-only parameters have no externally-usable name. When a function
10
10
accepting positional-only parameters is called, positional arguments are
11
11
mapped to these parameters based solely on their order.
@@ -20,7 +20,7 @@ Function signatures in this standard adhere to the following:
20
20
namespace >= 3.8. Alternatively, they can add guidance to their users in the
21
21
documentation to use the functions as if they were positional-only.
22
22
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.
24
24
25
25
*Rationale: this leads to more readable code, and it makes it easier to
26
26
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:
30
30
is called ``x ``. For functions that have multiple array parameters, those
31
31
parameters are called ``xi `` with ``i = 1, 2, ... `` (i.e., ``x1 ``, ``x2 ``).
32
32
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
35
35
adhere to the standard, adding type annotations is strongly recommended.
36
36
37
37
A function signature and description will look like:
@@ -57,3 +57,7 @@ A function signature and description will look like:
57
57
58
58
59
59
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