Skip to content

Commit bfbd2a8

Browse files
authored
PR: Transform static typing md to rst (#381)
* Transform static typing md to rst * fix warning
1 parent ba9e8ea commit bfbd2a8

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

spec/design_topics/static_typing.md renamed to spec/design_topics/static_typing.rst

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
1-
# Static typing
1+
Static typing
2+
=============
23

34
Good support for static typing both in array libraries and array-consuming
45
code is desirable. Therefore the exact type or set of types for each
56
parameter, keyword and return value is specified for functions and methods -
6-
see {ref}`function-and-method-signatures`. That section specifies arrays
7-
simply as `array`; what that means is dealt with in this section.
7+
see :ref:`function-and-method-signatures`. That section specifies arrays
8+
simply as ``array``; what that means is dealt with in this section.
89

910
Introducing type annotations in libraries became more relevant only when
1011
Python 2.7 support was dropped at the start of 2020. As a consequence, using
1112
type annotations with array libraries is largely still a work in progress.
12-
This version of the API standard does not deal with trying to type _array
13-
properties_ like shape, dimensionality or dtype, because that's not a solved
13+
This version of the API standard does not deal with trying to type *array
14+
properties* like shape, dimensionality or dtype, because that's not a solved
1415
problem in individual array libraries yet.
1516

16-
An `array` type annotation can mean either the type of one specific array
17+
An ``array`` type annotation can mean either the type of one specific array
1718
object, or some superclass or typing Protocol - as long as it is consistent
18-
with the array object specified in {ref}`array-object`. To illustrate by
19+
with the array object specified in :ref:`array-object`. To illustrate by
1920
example:
2021

21-
```python
22-
# `Array` is a particular class in the library
23-
def sin(x: Array, / ...) -> Array:
24-
...
25-
```
26-
27-
and
28-
29-
```python
30-
# There's some base class `_BaseArray`, and there may be multiple
31-
# array subclasses inside the library
32-
A = TypeVar('A', bound=_BaseArray)
33-
def sin(x: A, / ...) -> A:
34-
...
35-
```
22+
.. code-block:: python
23+
24+
# `Array` is a particular class in the library
25+
def sin(x: Array, / ...) -> Array:
26+
...
27+
28+
and
29+
30+
.. code-block:: python
31+
32+
# There's some base class `_BaseArray`, and there may be multiple
33+
# array subclasses inside the library
34+
A = TypeVar('A', bound=_BaseArray)
35+
def sin(x: A, / ...) -> A:
36+
...
37+
3638
should both be fine. There may be other variations possible. Also note that
3739
this standard does not require that input and output array types are the same
3840
(they're expected to be defined in the same library though). Given that
3941
array libraries don't have to be aware of other types of arrays defined in
40-
other libraries (see {ref}`assumptions-dependencies`), this should be enough
42+
other libraries (see :ref:`assumptions-dependencies`), this should be enough
4143
for a single array library.
4244

4345
That said, an array-consuming library aiming to support multiple array types

0 commit comments

Comments
 (0)