annotate
========
Function annotations.
Overview
========
**@annotate**
| Decorator to set a function's __annotations__ like Py3.
| https://www.python.org/dev/peps/pep-3107/
`PyPI record`_.
`Documentation`_.
Examples
--------
.. code:: python
from typing import Optional, Tuple, Union, Sequence
from annotate import annotate
from .lib import cached
from . import jni
from .jobjectbase import JObjectBase
from .jclass import JClass
from .jobject import JObject
class JArray(JObjectBase):
"""Java Array"""
@classmethod
@annotate('JArray', size=Union[int, long])
def newBooleanArray(cls, size):
...
...
@classmethod
@annotate('JArray', size=Union[int, long])
def newDoubleArray(cls, size):
...
@classmethod
@annotate('JArray', size=Union[int, long])
def newStringArray(cls, size):
...
@classmethod
@annotate('JArray', size=Union[int, long], component_class=JClass)
def newObjectArray(cls, size, component_class):
...
@annotate(jenv=jni.JNIEnv, jarr=jni.jarray, borrowed=bool)
def __init__(self, jenv, jarr, borrowed=False):
...
def __hash__(self):
return super(JArray, self).__hash__()
def __len__(self):
return self.getLength()
@annotate(JObject, borrowed=bool)
def asObject(self, borrowed=False):
...
@cached
@annotate(int)
def getLength(self):
...
@annotate(bool, idx=int)
def getBoolean(self, idx):
...
...
@annotate(float, idx=int)
def getDouble(self, idx):
...
@annotate(Optional[str], idx=int)
def getString(self, idx):
...
@annotate(Optional[JObject], idx=int)
def getObject(self, idx):
...
@annotate(idx=int, val=bool)
def setBoolean(self, idx, val):
...
@annotate(idx=int, val=str)
def setChar(self, idx, val):
...
...
@annotate(idx=int, val=Union[int, long])
def setLong(self, idx, val):
...
@annotate(idx=int, val=float)
def setDouble(self, idx, val):
...
@annotate(idx=int, val=Optional[str])
def setString(self, idx, val):
...
@annotate(idx=int, val=Optional[JObject])
def setObject(self, idx, val):
...
@annotate('JArray', start=int, stop=int, step=int)
def getBooleanSlice(self, start, stop, step):
...
...
@annotate('JArray', start=int, stop=int, step=int)
def getDoubleSlice(self, start, stop, step):
...
@annotate('JArray', start=int, stop=int, step=int)
def getStringSlice(self, start, stop, step):
...
@annotate('JArray', start=int, stop=int, step=int)
def getObjectSlice(self, start, stop, step):
...
@annotate(start=int, stop=int, step=int, val=Sequence[bool])
def setBooleanSlice(self, start, stop, step, val):
...
@annotate(start=int, stop=int, step=int, val=Union[Sequence[str], str])
def setCharSlice(self, start, stop, step, val):
...
@annotate(start=int, stop=int, step=int,
val=Union[Sequence[Union[int,bytes]], (bytes, bytearray)])
def setByteSlice(self, start, stop, step, val):
...
...
@annotate(start=int, stop=int, step=int, val=Sequence[float])
def setDoubleSlice(self, start, stop, step, val):
...
@annotate(start=int, stop=int, step=int, val=Sequence[Optional[str]])
def setStringSlice(self, start, stop, step, val):
...
@annotate(start=int, stop=int, step=int, val=Sequence[Optional[JObject]])
def setObjectSlice(self, start, stop, step, val):
...
@annotate(Tuple)
def getBooleanBuffer(self):
with self.jvm as (jvm, jenv):
is_copy = jni.jboolean()
return jenv.GetBooleanArrayElements(self._jobj, is_copy), jni.sizeof(jni.jboolean), b"B", is_copy
...
@annotate(Tuple)
def getDoubleBuffer(self):
with self.jvm as (jvm, jenv):
is_copy = jni.jboolean()
return jenv.GetDoubleArrayElements(self._jobj, is_copy), jni.sizeof(jni.jdouble), b"d", is_copy
@annotate(buf=object)
def releaseBooleanBuffer(self, buf):
with self.jvm as (jvm, jenv):
jenv.ReleaseBooleanArrayElements(self._jobj, jni.cast(buf, jni.POINTER(jni.jboolean)))
...
@annotate(buf=object)
def releaseDoubleBuffer(self, buf):
with self.jvm as (jvm, jenv):
jenv.ReleaseDoubleArrayElements(self._jobj, jni.cast(buf, jni.POINTER(jni.jdouble)))
Installation
============
Prerequisites:
+ Python 3.9 or higher
* https://www.python.org/
+ pip and setuptools
* https://pypi.org/project/pip/
* https://pypi.org/project/setuptools/
To install run:
.. parsed-literal::
python -m pip install --upgrade |package|
Development
===========
Prerequisites:
+ Development is strictly based on *tox*. To install it run::
python -m pip install --upgrade tox
Visit `Development page`_.
Installation from sources:
clone the sources:
.. parsed-literal::
git clone |respository| |package|
and run:
.. parsed-literal::
python -m pip install ./|package|
or on development mode:
.. parsed-literal::
python -m pip install --editable ./|package|
License
=======
| |copyright|
| Licensed under the zlib/libpng License
| https://opensource.org/license/zlib
| Please refer to the accompanying LICENSE file.
Authors
=======
* Adam Karpierz <adam@karpierz.net>
.. |package| replace:: annotate
.. |package_bold| replace:: **annotate**
.. |copyright| replace:: Copyright (c) 2012-2024 Adam Karpierz
.. |respository| replace:: https://github.com/karpierz/annotate.git
.. _Development page: https://github.com/karpierz/annotate
.. _PyPI record: https://pypi.org/project/annotate/
.. _Documentation: https://annotate.readthedocs.io/
Changelog
=========
1.1.3 (2024-12-13)
------------------
- Source distribution (\*.tar.gz now) is compliant with PEP-0625.
- 100% code linting.
- Tox configuration is now in native (toml) format.
- Setup (dependencies) update.
1.1.2 (2024-10-30)
------------------
- Setup (dependencies) update.
1.1.1 (2024-10-09)
------------------
- Setup (dependencies) update.
1.1.0 (2024-09-30)
------------------
- Drop support for Python 3.8
- Setup (dependencies) update.
1.0.20 (2024-08-13)
-------------------
- Add support for Python 3.12 and 3.13
- Drop support for Python 3.7
- Setup (dependencies) update.
1.0.19 (2022-10-18)
-------------------
- Tox configuration has been moved to pyproject.toml
1.0.18 (2022-08-22)
-------------------
- Setup update.
1.0.17 (2022-07-24)
-------------------
- Add support for Python 3.10 and 3.11
- Setup update (currently based mainly on pyproject.toml).
1.0.16 (2022-01-10)
-------------------
- Drop support for Python 2, 3.5 and 3.6
- Copyright year update.
- Setup update.
1.0.15 (2020-10-18)
-------------------
- Setup: fix an improper dependencies versions.
- Setup general update and cleanup.
- Fixed docs setup.
1.0.8 (2019-05-21)
------------------
- Update required setuptools version.
- Setup update and improvements.
1.0.7 (2018-11-08)
------------------
- Drop support for Python 2.6 and 3.0-3.3
- Update required setuptools version.
1.0.6 (2018-05-08)
------------------
- Update required setuptools version.
- Improve and simplify setup and packaging.
1.0.5 (2018-02-26)
------------------
- Improve and simplify setup and packaging.
1.0.4 (2018-01-28)
------------------
- Fix a bug and inconsistencies in tox.ini
- Update of README.rst.
1.0.1 (2018-01-24)
------------------
- Update required Sphinx version.
- Update doc Sphinx configuration files.
1.0.0 (2017-11-18)
------------------
- Setup improvements.
- Other minor improvements.
0.7.4 (2017-01-05)
------------------
- Minor setup improvements.
0.7.3 (2016-09-25)
------------------
- Fix bug in setup.py
0.7.1 (2016-09-25)
------------------
- More PEP8 compliant
0.6.7 (2016-09-24)
------------------
- Minor description suplement
0.6.4 (2016-09-23)
------------------
- Simplify package structure.
0.6.3 (2016-06-19)
------------------
- | Fix incompatibility for older versions of setuptools.
| Add example.
0.6.0 (2015-08-17)
------------------
- Python3 support.
0.5.1 (2015-02-27)
------------------
- | Remove 'returns' as keyword argument for declare return type.
| For now, the type of returned value should be declared by the
| first positional argument.
0.3.3 (2014-09-15)
------------------
- Add wheels.
0.3.2 (2014-09-13)
------------------
- Standarize package.
0.3.0 (2014-09-06)
------------------
- Standarize package.
- Cosmetic changes.
0.2.6 (2014-06-10)
------------------
- Portable setup.py.
0.2.5 (2014-06-10)
------------------
- Cosmetic changes.
0.2.3 (2012-10-13)
------------------
- Initial release.
Raw data
{
"_id": null,
"home_page": null,
"name": "annotate",
"maintainer": "Adam Karpierz",
"docs_url": null,
"requires_python": "<4.0.0,>=3.9.0",
"maintainer_email": "adam@karpierz.net",
"keywords": "annotate, typing, decorator",
"author": "Adam Karpierz",
"author_email": "adam@karpierz.net",
"download_url": "https://files.pythonhosted.org/packages/d1/54/94dc4198e2e6b81532f26f55c41bd4ddefb267ef704846edc14428aedc42/annotate-1.1.3.tar.gz",
"platform": "any",
"description": "annotate\r\n========\r\n\r\nFunction annotations.\r\n\r\nOverview\r\n========\r\n\r\n**@annotate**\r\n\r\n| Decorator to set a function's __annotations__ like Py3.\r\n| https://www.python.org/dev/peps/pep-3107/\r\n\r\n`PyPI record`_.\r\n\r\n`Documentation`_.\r\n\r\nExamples\r\n--------\r\n\r\n.. code:: python\r\n\r\n from typing import Optional, Tuple, Union, Sequence\r\n from annotate import annotate\r\n\r\n from .lib import cached\r\n from . import jni\r\n\r\n from .jobjectbase import JObjectBase\r\n from .jclass import JClass\r\n from .jobject import JObject\r\n\r\n\r\n class JArray(JObjectBase):\r\n \"\"\"Java Array\"\"\"\r\n\r\n @classmethod\r\n @annotate('JArray', size=Union[int, long])\r\n def newBooleanArray(cls, size):\r\n ...\r\n ...\r\n @classmethod\r\n @annotate('JArray', size=Union[int, long])\r\n def newDoubleArray(cls, size):\r\n ...\r\n @classmethod\r\n @annotate('JArray', size=Union[int, long])\r\n def newStringArray(cls, size):\r\n ...\r\n @classmethod\r\n @annotate('JArray', size=Union[int, long], component_class=JClass)\r\n def newObjectArray(cls, size, component_class):\r\n ...\r\n\r\n @annotate(jenv=jni.JNIEnv, jarr=jni.jarray, borrowed=bool)\r\n def __init__(self, jenv, jarr, borrowed=False):\r\n ...\r\n\r\n def __hash__(self):\r\n return super(JArray, self).__hash__()\r\n\r\n def __len__(self):\r\n return self.getLength()\r\n\r\n @annotate(JObject, borrowed=bool)\r\n def asObject(self, borrowed=False):\r\n ...\r\n\r\n @cached\r\n @annotate(int)\r\n def getLength(self):\r\n ...\r\n\r\n @annotate(bool, idx=int)\r\n def getBoolean(self, idx):\r\n ...\r\n ...\r\n @annotate(float, idx=int)\r\n def getDouble(self, idx):\r\n ...\r\n @annotate(Optional[str], idx=int)\r\n def getString(self, idx):\r\n ...\r\n @annotate(Optional[JObject], idx=int)\r\n def getObject(self, idx):\r\n ...\r\n\r\n @annotate(idx=int, val=bool)\r\n def setBoolean(self, idx, val):\r\n ...\r\n @annotate(idx=int, val=str)\r\n def setChar(self, idx, val):\r\n ...\r\n ...\r\n @annotate(idx=int, val=Union[int, long])\r\n def setLong(self, idx, val):\r\n ...\r\n @annotate(idx=int, val=float)\r\n def setDouble(self, idx, val):\r\n ...\r\n @annotate(idx=int, val=Optional[str])\r\n def setString(self, idx, val):\r\n ...\r\n @annotate(idx=int, val=Optional[JObject])\r\n def setObject(self, idx, val):\r\n ...\r\n\r\n @annotate('JArray', start=int, stop=int, step=int)\r\n def getBooleanSlice(self, start, stop, step):\r\n ...\r\n ...\r\n @annotate('JArray', start=int, stop=int, step=int)\r\n def getDoubleSlice(self, start, stop, step):\r\n ...\r\n @annotate('JArray', start=int, stop=int, step=int)\r\n def getStringSlice(self, start, stop, step):\r\n ...\r\n @annotate('JArray', start=int, stop=int, step=int)\r\n def getObjectSlice(self, start, stop, step):\r\n ...\r\n\r\n @annotate(start=int, stop=int, step=int, val=Sequence[bool])\r\n def setBooleanSlice(self, start, stop, step, val):\r\n ...\r\n @annotate(start=int, stop=int, step=int, val=Union[Sequence[str], str])\r\n def setCharSlice(self, start, stop, step, val):\r\n ...\r\n @annotate(start=int, stop=int, step=int,\r\n val=Union[Sequence[Union[int,bytes]], (bytes, bytearray)])\r\n def setByteSlice(self, start, stop, step, val):\r\n ...\r\n ...\r\n @annotate(start=int, stop=int, step=int, val=Sequence[float])\r\n def setDoubleSlice(self, start, stop, step, val):\r\n ...\r\n @annotate(start=int, stop=int, step=int, val=Sequence[Optional[str]])\r\n def setStringSlice(self, start, stop, step, val):\r\n ...\r\n @annotate(start=int, stop=int, step=int, val=Sequence[Optional[JObject]])\r\n def setObjectSlice(self, start, stop, step, val):\r\n ...\r\n\r\n @annotate(Tuple)\r\n def getBooleanBuffer(self):\r\n with self.jvm as (jvm, jenv):\r\n is_copy = jni.jboolean()\r\n return jenv.GetBooleanArrayElements(self._jobj, is_copy), jni.sizeof(jni.jboolean), b\"B\", is_copy\r\n ...\r\n @annotate(Tuple)\r\n def getDoubleBuffer(self):\r\n with self.jvm as (jvm, jenv):\r\n is_copy = jni.jboolean()\r\n return jenv.GetDoubleArrayElements(self._jobj, is_copy), jni.sizeof(jni.jdouble), b\"d\", is_copy\r\n\r\n @annotate(buf=object)\r\n def releaseBooleanBuffer(self, buf):\r\n with self.jvm as (jvm, jenv):\r\n jenv.ReleaseBooleanArrayElements(self._jobj, jni.cast(buf, jni.POINTER(jni.jboolean)))\r\n ...\r\n @annotate(buf=object)\r\n def releaseDoubleBuffer(self, buf):\r\n with self.jvm as (jvm, jenv):\r\n jenv.ReleaseDoubleArrayElements(self._jobj, jni.cast(buf, jni.POINTER(jni.jdouble)))\r\n\r\nInstallation\r\n============\r\n\r\nPrerequisites:\r\n\r\n+ Python 3.9 or higher\r\n\r\n * https://www.python.org/\r\n\r\n+ pip and setuptools\r\n\r\n * https://pypi.org/project/pip/\r\n * https://pypi.org/project/setuptools/\r\n\r\nTo install run:\r\n\r\n .. parsed-literal::\r\n\r\n python -m pip install --upgrade |package|\r\n\r\nDevelopment\r\n===========\r\n\r\nPrerequisites:\r\n\r\n+ Development is strictly based on *tox*. To install it run::\r\n\r\n python -m pip install --upgrade tox\r\n\r\nVisit `Development page`_.\r\n\r\nInstallation from sources:\r\n\r\nclone the sources:\r\n\r\n .. parsed-literal::\r\n\r\n git clone |respository| |package|\r\n\r\nand run:\r\n\r\n .. parsed-literal::\r\n\r\n python -m pip install ./|package|\r\n\r\nor on development mode:\r\n\r\n .. parsed-literal::\r\n\r\n python -m pip install --editable ./|package|\r\n\r\nLicense\r\n=======\r\n\r\n | |copyright|\r\n | Licensed under the zlib/libpng License\r\n | https://opensource.org/license/zlib\r\n | Please refer to the accompanying LICENSE file.\r\n\r\nAuthors\r\n=======\r\n\r\n* Adam Karpierz <adam@karpierz.net>\r\n\r\n.. |package| replace:: annotate\r\n.. |package_bold| replace:: **annotate**\r\n.. |copyright| replace:: Copyright (c) 2012-2024 Adam Karpierz\r\n.. |respository| replace:: https://github.com/karpierz/annotate.git\r\n.. _Development page: https://github.com/karpierz/annotate\r\n.. _PyPI record: https://pypi.org/project/annotate/\r\n.. _Documentation: https://annotate.readthedocs.io/\r\n\r\nChangelog\r\n=========\r\n\r\n1.1.3 (2024-12-13)\r\n------------------\r\n- Source distribution (\\*.tar.gz now) is compliant with PEP-0625.\r\n- 100% code linting.\r\n- Tox configuration is now in native (toml) format.\r\n- Setup (dependencies) update.\r\n\r\n1.1.2 (2024-10-30)\r\n------------------\r\n- Setup (dependencies) update.\r\n\r\n1.1.1 (2024-10-09)\r\n------------------\r\n- Setup (dependencies) update.\r\n\r\n1.1.0 (2024-09-30)\r\n------------------\r\n- Drop support for Python 3.8\r\n- Setup (dependencies) update.\r\n\r\n1.0.20 (2024-08-13)\r\n-------------------\r\n- Add support for Python 3.12 and 3.13\r\n- Drop support for Python 3.7\r\n- Setup (dependencies) update.\r\n\r\n1.0.19 (2022-10-18)\r\n-------------------\r\n- Tox configuration has been moved to pyproject.toml\r\n\r\n1.0.18 (2022-08-22)\r\n-------------------\r\n- Setup update.\r\n\r\n1.0.17 (2022-07-24)\r\n-------------------\r\n- Add support for Python 3.10 and 3.11\r\n- Setup update (currently based mainly on pyproject.toml).\r\n\r\n1.0.16 (2022-01-10)\r\n-------------------\r\n- Drop support for Python 2, 3.5 and 3.6\r\n- Copyright year update.\r\n- Setup update.\r\n\r\n1.0.15 (2020-10-18)\r\n-------------------\r\n- Setup: fix an improper dependencies versions.\r\n- Setup general update and cleanup.\r\n- Fixed docs setup.\r\n\r\n1.0.8 (2019-05-21)\r\n------------------\r\n- Update required setuptools version.\r\n- Setup update and improvements.\r\n\r\n1.0.7 (2018-11-08)\r\n------------------\r\n- Drop support for Python 2.6 and 3.0-3.3\r\n- Update required setuptools version.\r\n\r\n1.0.6 (2018-05-08)\r\n------------------\r\n- Update required setuptools version.\r\n- Improve and simplify setup and packaging.\r\n\r\n1.0.5 (2018-02-26)\r\n------------------\r\n- Improve and simplify setup and packaging.\r\n\r\n1.0.4 (2018-01-28)\r\n------------------\r\n- Fix a bug and inconsistencies in tox.ini\r\n- Update of README.rst.\r\n\r\n1.0.1 (2018-01-24)\r\n------------------\r\n- Update required Sphinx version.\r\n- Update doc Sphinx configuration files.\r\n\r\n1.0.0 (2017-11-18)\r\n------------------\r\n- Setup improvements.\r\n- Other minor improvements.\r\n\r\n0.7.4 (2017-01-05)\r\n------------------\r\n- Minor setup improvements.\r\n\r\n0.7.3 (2016-09-25)\r\n------------------\r\n- Fix bug in setup.py\r\n\r\n0.7.1 (2016-09-25)\r\n------------------\r\n- More PEP8 compliant\r\n\r\n0.6.7 (2016-09-24)\r\n------------------\r\n- Minor description suplement\r\n\r\n0.6.4 (2016-09-23)\r\n------------------\r\n- Simplify package structure.\r\n\r\n0.6.3 (2016-06-19)\r\n------------------\r\n- | Fix incompatibility for older versions of setuptools.\r\n | Add example.\r\n\r\n0.6.0 (2015-08-17)\r\n------------------\r\n- Python3 support.\r\n\r\n0.5.1 (2015-02-27)\r\n------------------\r\n- | Remove 'returns' as keyword argument for declare return type.\r\n | For now, the type of returned value should be declared by the\r\n | first positional argument.\r\n\r\n0.3.3 (2014-09-15)\r\n------------------\r\n- Add wheels.\r\n\r\n0.3.2 (2014-09-13)\r\n------------------\r\n- Standarize package.\r\n\r\n0.3.0 (2014-09-06)\r\n------------------\r\n- Standarize package.\r\n- Cosmetic changes.\r\n\r\n0.2.6 (2014-06-10)\r\n------------------\r\n- Portable setup.py.\r\n\r\n0.2.5 (2014-06-10)\r\n------------------\r\n- Cosmetic changes.\r\n\r\n0.2.3 (2012-10-13)\r\n------------------\r\n- Initial release.\r\n",
"bugtrack_url": null,
"license": "zlib/libpng License ; https://opensource.org/license/zlib",
"summary": "Decorator to set a function's __annotations__ like Py3.",
"version": "1.1.3",
"project_urls": {
"Documentation": "https://annotate2.readthedocs.io/",
"Download": "https://pypi.org/project/annotate/",
"Homepage": "https://pypi.org/project/annotate/",
"Issues": "https://github.com/karpierz/annotate/issues",
"Source": "https://github.com/karpierz/annotate"
},
"split_keywords": [
"annotate",
" typing",
" decorator"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c31190b4c1130032a3090e2fcf4d60f435863f6c32fd8d38a2294e8fc5aa779a",
"md5": "49e922e9fd747fdd5e1bff02f5da3af7",
"sha256": "7423e9e8e54e38718d4f0044091ce3c005e97055e7c9a781bdb0865b1797dbd6"
},
"downloads": -1,
"filename": "annotate-1.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "49e922e9fd747fdd5e1bff02f5da3af7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0.0,>=3.9.0",
"size": 5763,
"upload_time": "2024-12-15T16:02:17",
"upload_time_iso_8601": "2024-12-15T16:02:17.510112Z",
"url": "https://files.pythonhosted.org/packages/c3/11/90b4c1130032a3090e2fcf4d60f435863f6c32fd8d38a2294e8fc5aa779a/annotate-1.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d15494dc4198e2e6b81532f26f55c41bd4ddefb267ef704846edc14428aedc42",
"md5": "8d3a384ad91e94a269dd6de89a67247e",
"sha256": "2b0548a5d495e5c73f0f9bb29518503e1137665ed33e7da1e1ef0a9011eb6d11"
},
"downloads": -1,
"filename": "annotate-1.1.3.tar.gz",
"has_sig": false,
"md5_digest": "8d3a384ad91e94a269dd6de89a67247e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0.0,>=3.9.0",
"size": 13971,
"upload_time": "2024-12-15T16:02:20",
"upload_time_iso_8601": "2024-12-15T16:02:20.007740Z",
"url": "https://files.pythonhosted.org/packages/d1/54/94dc4198e2e6b81532f26f55c41bd4ddefb267ef704846edc14428aedc42/annotate-1.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-15 16:02:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "karpierz",
"github_project": "annotate",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "annotate"
}