|
3 | 3 | # typing.py
|
4 | 4 | """
|
5 | 5 | Common aliases for type hinting
|
| 6 | +
|
| 7 | +**Data:** |
| 8 | +
|
| 9 | +.. csv-table:: |
| 10 | + :widths: 5, 20 |
| 11 | +
|
| 12 | + :data:`~.PathLike`, Type hint for objects that represent filesystem paths. |
| 13 | + :data:`~.AnyNumber`, Type hint for numbers. |
| 14 | + :data:`~.WrapperDescriptorType`, The type of methods of some built-in data types and base classes. |
| 15 | + :data:`~.MethodWrapperType`, The type of *bound* methods of some built-in data types and base classes. |
| 16 | + :data:`~.MethodDescriptorType`, The type of methods of some built-in data types. |
| 17 | + :data:`~.ClassMethodDescriptorType`, The type of *unbound* class methods of some built-in data types. |
| 18 | +
|
6 | 19 | """
|
7 | 20 | #
|
8 | 21 | # Copyright © 2020 Dominic Davis-Foster <[email protected]>
|
|
33 | 46 | # 3rd party
|
34 | 47 | from typing_extensions import Protocol
|
35 | 48 |
|
36 |
| -__all__ = ["PathLike", "AnyNumber", "check_membership", "JsonLibrary"] |
| 49 | +__all__ = [ |
| 50 | + "PathLike", |
| 51 | + "AnyNumber", |
| 52 | + "check_membership", |
| 53 | + "JsonLibrary", |
| 54 | + "WrapperDescriptorType", |
| 55 | + "MethodWrapperType", |
| 56 | + "MethodDescriptorType", |
| 57 | + "ClassMethodDescriptorType", |
| 58 | + ] |
37 | 59 |
|
38 | 60 | #: Type hint for objects that represent filesystem paths.
|
39 | 61 | PathLike = Union[str, pathlib.Path, os.PathLike]
|
@@ -124,3 +146,29 @@ def loads(
|
124 | 146 | :param object_pairs_hook:
|
125 | 147 | :param kwds:
|
126 | 148 | """
|
| 149 | + |
| 150 | + |
| 151 | +# Backported from https://github.com/python/cpython/blob/master/Lib/types.py |
| 152 | +# Licensed under the Python Software Foundation License Version 2. |
| 153 | +# Copyright © 2001-2020 Python Software Foundation. All rights reserved. |
| 154 | +# Copyright © 2000 BeOpen.com . All rights reserved. |
| 155 | +# Copyright © 1995-2000 Corporation for National Research Initiatives . All rights reserved. |
| 156 | +# Copyright © 1991-1995 Stichting Mathematisch Centrum . All rights reserved. |
| 157 | +# |
| 158 | + |
| 159 | +# if domdf_python_tools.DOCUMENTING: |
| 160 | +# WrapperDescriptorType = '' |
| 161 | +# """ |
| 162 | +# The type of methods of some built-in data types and base classes such as |
| 163 | +# :meth:`object.__init__` or :meth:`object.__lt__`. |
| 164 | +# """ |
| 165 | +# |
| 166 | +# MethodWrapperType = '' |
| 167 | +# MethodDescriptorType = '' |
| 168 | +# ClassMethodDescriptorType = '' |
| 169 | + |
| 170 | +# else: |
| 171 | +WrapperDescriptorType = type(object.__init__) |
| 172 | +MethodWrapperType = type(object().__str__) |
| 173 | +MethodDescriptorType = type(str.join) |
| 174 | +ClassMethodDescriptorType = type(dict.__dict__['fromkeys']) |
0 commit comments