summaryrefslogtreecommitdiffstats
path: root/Python/Dependencies/future-0.18.2/docs/func_annotations.rst
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2022-12-17 17:26:16 -0800
committeryum <yum.food.vr@gmail.com>2022-12-17 17:26:16 -0800
commit4d836989720523cd0363927e3e066f56b9dc445c (patch)
treef7a9ff7cb50eda1ff29e91c78067dcc5e0ce6233 /Python/Dependencies/future-0.18.2/docs/func_annotations.rst
parentda754e9cf5b192239826aa1619e1ada3c98daa45 (diff)
Check in `future` package
I hit some issues installing Whisper and had to embed this package. I haven't taken the time to deeply understand what's going on. I think that embedded Python follows different rules about resolving module paths than regular system Python. Basically, `future`'s setup.py has a line like `import src`, where `src` is a module inside future (like `future/src/__init__.py`). This doesn't work unless we put that directory on the search path.
Diffstat (limited to 'Python/Dependencies/future-0.18.2/docs/func_annotations.rst')
-rw-r--r--Python/Dependencies/future-0.18.2/docs/func_annotations.rst37
1 files changed, 37 insertions, 0 deletions
diff --git a/Python/Dependencies/future-0.18.2/docs/func_annotations.rst b/Python/Dependencies/future-0.18.2/docs/func_annotations.rst
new file mode 100644
index 0000000..a298f2c
--- /dev/null
+++ b/Python/Dependencies/future-0.18.2/docs/func_annotations.rst
@@ -0,0 +1,37 @@
+.. _func_annotations:
+
+Function annotations
+====================
+
+Function annotations are a piece of syntax introduced in Python 3.0 that was
+not backported to Python 2.x. (See PEP 3107:
+http://www.python.org/dev/peps/pep-3107/). They cause Python 2 to raise a
+SyntaxError.
+
+To rewrite Python 3 code with function annotations to be compatible with both
+Python 3 and Python 2, you can replace the annotation syntax with a dictionary
+called ``__annotations__`` as an attribute on your functions. For example, code
+such as this::
+
+ def _parse(self, filename: str, dir='.') -> list:
+ pass
+
+can be re-expressed like this::
+
+ def _parse(self, filename, dir='.'):
+ pass
+ _parse.__annotations__ = {'filename': str, 'return': list}
+
+As described in PEP 3107, the annotation for a function's return value
+corresponds to the ``'return'`` key in the dictionary.
+
+(Note that PEP 3107 describes annotations as belonging to a
+``func_annotations`` attribute. This attribute was renamed in Python 3.2 to
+``__annotations__``.)
+
+Be aware that some libraries that consume function annotations, such as
+`Reticulated <https://github.com/mvitousek/reticulated>`_, have their own
+semantics for supporting earlier Python versions, such as decorators. If you
+are using such a library, please use its own mechanism for providing
+compatibility with earlier Python versions, rather than the generic equivalent
+above.