Skip to main content

Overview

This is designed to add and process annotations to python objects, a-la Java Annotations.

Annotations are just metadata, something that is not directly used by code itself but can be queried by other parts of the program.

Python itself doesn’t need special low-level implementations in order to support metadata, this library’s target is just to provide a standard way of setting and querying metadata from python objects.

Python 3 actually contains a basic version of metadata, but it’s limited to the arguments and return values of functions; this library is designed to extend such support to other objects, so you can annotate a class, a function or any object with any kind of data.

Current status

Currently contains a PEP-3107 compatible signature annotation implementation for Python 2.x.

Example code

Basic function annotation:

>>> from annopyte.annotations.signature import annotate_f
>>> @annotate_f("return_value_annotation", param1="asd", param2="fgh")
... def myfunc(param1, param2=None):
...     pass
...
>>> print myfunc.__annotations__
{'return': 'return_value_annotation', 'param2': 'fgh', 'param1': 'asd'}
>>>

Prospective code ( to be done )

That’s the basic idea I’d like to implement for metadata usage:

class Author(Annotation)
    name = "default"

@Author(name="John Doe")
class MyClass(object):
    pass

>>> query_for_metadata("mypackage", Author, name="John Doe")
[<class 'mypackage.subpackage.MyClass'>]
>>>

That’s it.

Homepage

http://annopyte.franzoni.eu

Support and discussions

pydenji-users@googlegroups.com

https://groups.google.com/d/forum/pydenji-users

Contact me

Alan Franzoni <username at franzoni.eu> (please note: write LITERALLY username in the email address!)

Release files for annopyte 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for annopyte 0.3.1
File Size Uploaded
annopyte-0.3.1.zip 8.6 kB Details

Release files / annopyte-0.3.1.zip

Download URL annopyte-0.3.1.zip
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
de78362cb01584ca23b9ffb9a9ad0f1ed678b84d2948eb0942c31e49225cfc9b
BLAKE2b-256 checksum
How to use checksums
722de4c7aafe8b783368c3fdce8b71e629c23b4a356676746f21ec10ecfd92f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.1 This release

1 release file

0.3.0

2 release files

0.2.1

1 release file

0.2

1 release file

0.1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page