Skip to content

Commit 4399dbd

Browse files
committed
Tidy up docs for typing.py
1 parent 3928b43 commit 4399dbd

File tree

3 files changed

+74
-26
lines changed

3 files changed

+74
-26
lines changed

doc-source/api/typing.rst

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,27 @@
22
:mod:`~domdf_python_tools.typing`
33
=================================
44

5-
.. autosummary-widths:: 11/32
6-
:html: 25/100
5+
Various type annotation aids.
6+
7+
.. module:: domdf_python_tools.typing
8+
9+
Type Hints
10+
------------
11+
12+
.. autosummary2::
13+
14+
~domdf_python_tools.typing.PathLike
15+
~domdf_python_tools.typing.PathType
16+
~domdf_python_tools.typing.AnyNumber
17+
~domdf_python_tools.typing.WrapperDescriptorType, The type of methods of some built-in data types and base classes.
18+
~domdf_python_tools.typing.MethodWrapperType, The type of *bound* methods of some built-in data types and base classes.
19+
~domdf_python_tools.typing.MethodDescriptorType, The type of methods of some built-in data types.
20+
~domdf_python_tools.typing.ClassMethodDescriptorType, The type of *unbound* class methods of some built-in data types.
21+
22+
.. autogenericalias:: PathLike
23+
.. autotypevar:: PathType
24+
.. autogenericalias:: AnyNumber
725

8-
.. automodule:: domdf_python_tools.typing
9-
:autosummary-sections: Functions ;; Classes
1026

1127
.. data:: WrapperDescriptorType
1228

@@ -15,6 +31,7 @@
1531

1632
.. versionadded:: 0.8.0
1733

34+
1835
.. data:: MethodWrapperType
1936

2037
The type of *bound* methods of some built-in data types and base classes.
@@ -36,3 +53,35 @@
3653
``dict.__dict__['fromkeys']``.
3754

3855
.. versionadded:: 0.8.0
56+
57+
58+
Protocols
59+
------------
60+
61+
.. autosummary::
62+
63+
~domdf_python_tools.typing.JsonLibrary
64+
~domdf_python_tools.typing.HasHead
65+
~domdf_python_tools.typing.String
66+
~domdf_python_tools.typing.FrameOrSeries
67+
~domdf_python_tools.typing.SupportsIndex
68+
~domdf_python_tools.typing.SupportsLessThan
69+
~domdf_python_tools.typing.SupportsLessEqual
70+
~domdf_python_tools.typing.SupportsGreaterThan
71+
~domdf_python_tools.typing.SupportsGreaterEqual
72+
73+
.. autoprotocol:: JsonLibrary
74+
.. autoprotocol:: HasHead
75+
.. autoprotocol:: String
76+
.. autoprotocol:: FrameOrSeries
77+
.. autoprotocol:: SupportsIndex
78+
.. autoprotocol:: SupportsLessThan
79+
.. autoprotocol:: SupportsLessEqual
80+
.. autoprotocol:: SupportsGreaterThan
81+
.. autoprotocol:: SupportsGreaterEqual
82+
83+
84+
Utility Functions
85+
---------------------
86+
87+
.. autofunction:: check_membership

domdf_python_tools/typing.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,7 @@
22
#
33
# typing.py
44
"""
5-
Common aliases for type hinting.
6-
7-
**Data:**
8-
9-
.. autosummary2::
10-
11-
~domdf_python_tools.typing.PathLike
12-
~domdf_python_tools.typing.AnyNumber
13-
~domdf_python_tools.typing.WrapperDescriptorType, The type of methods of some built-in data types and base classes.
14-
~domdf_python_tools.typing.MethodWrapperType, The type of *bound* methods of some built-in data types and base classes.
15-
~domdf_python_tools.typing.MethodDescriptorType, The type of methods of some built-in data types.
16-
~domdf_python_tools.typing.ClassMethodDescriptorType, The type of *unbound* class methods of some built-in data types.
17-
5+
Various type annotation aids.
186
"""
197
#
208
# Copyright © 2020 Dominic Davis-Foster <[email protected]>
@@ -70,12 +58,11 @@
7058
"PathLike",
7159
"PathType",
7260
"AnyNumber",
73-
"check_membership",
74-
"JsonLibrary",
7561
"WrapperDescriptorType",
7662
"MethodWrapperType",
7763
"MethodDescriptorType",
7864
"ClassMethodDescriptorType",
65+
"JsonLibrary",
7966
"HasHead",
8067
"String",
8168
"FrameOrSeries",
@@ -84,6 +71,7 @@
8471
"SupportsLessEqual",
8572
"SupportsGreaterThan",
8673
"SupportsGreaterEqual",
74+
"check_membership",
8775
]
8876

8977
PathLike = Union[str, pathlib.Path, os.PathLike]
@@ -126,9 +114,9 @@ def check_membership(obj: Any, type_: Union[Type, object]) -> bool:
126114

127115
class JsonLibrary(Protocol):
128116
"""
129-
Type hint for functions that take a JSON serialisation-deserialisation library as an argument.
117+
:class:`typing.Protocol` for libraries that implement the same API as :mod:`json`.
130118
131-
The library implement at least the following methods:
119+
Useful for annotating functions which take a JSON serialisation-deserialisation library as an argument.
132120
"""
133121

134122
@staticmethod
@@ -262,7 +250,10 @@ class SupportsLessThan(Protocol):
262250
.. versionadded:: 3.0.0
263251
"""
264252

265-
def __lt__(self, __other: Any) -> bool: ...
253+
def __lt__(self, __other: Any) -> bool:
254+
"""
255+
Return ``self < value``.
256+
"""
266257

267258

268259
class SupportsLessEqual(Protocol):
@@ -272,7 +263,10 @@ class SupportsLessEqual(Protocol):
272263
.. versionadded:: 3.0.0
273264
"""
274265

275-
def __le__(self, __other: Any) -> bool: ...
266+
def __le__(self, __other: Any) -> bool:
267+
"""
268+
Return ``self <= value``.
269+
"""
276270

277271

278272
class SupportsGreaterThan(Protocol):
@@ -282,7 +276,10 @@ class SupportsGreaterThan(Protocol):
282276
.. versionadded:: 3.0.0
283277
"""
284278

285-
def __gt__(self, __other: Any) -> bool: ...
279+
def __gt__(self, __other: Any) -> bool:
280+
"""
281+
Return ``self > value``.
282+
"""
286283

287284

288285
class SupportsGreaterEqual(Protocol):
@@ -292,4 +289,7 @@ class SupportsGreaterEqual(Protocol):
292289
.. versionadded:: 3.0.0
293290
"""
294291

295-
def __ge__(self, __other: Any) -> bool: ...
292+
def __ge__(self, __other: Any) -> bool:
293+
"""
294+
Return ``self >= value``.
295+
"""

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ extend-exclude = doc-source,old,build,dist,__pkginfo__.py,setup.py,venv
145145
rst-directives =
146146
TODO
147147
autosummary-widths
148-
autosummary2
149148
autovariable
150149
bold-title
151150
envvar

0 commit comments

Comments
 (0)