Skip to content

Commit 0fe08ae

Browse files
committed
A few updates to 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 gh-475
1 parent 8fe8b08 commit 0fe08ae

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

spec/draft/API_specification/function_and_method_signatures.rst

Lines changed: 8 additions & 4 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy