Miss extension methods from other languages? Python can have those too.
Installation
pip install extensified==0.3.0
Usage
from dataclasses import dataclass
from datetime import datetime
from extensified import extension_on
@dataclass
class Customer:
name: str
email: str
created_at: datetime = datetime.now()
@extension_on(Customer)
class CustomerStringReprExtension:
@property
def rfc5322_email(self) -> str:
return f'{self.name} <{self.email}>'
@property
def ldap_dn(self) -> str:
email_domain = self.email.split('@')[1]
return f'cn={self.name},ou=Users,dc={email_domain.replace(".", ",dc=")}'
@property
def vcard_name(self) -> str:
surname = self.name.split()[-1]
given_names = ' '.join(self.name.split()[:-1])
return f'FN:{self.name}\nN:{surname};{given_names};;;'
customer = Customer("John Doe", "john@example.com")
print(customer.rfc5322_email)
print(customer.ldap_dn)
print(customer.vcard_name)
Limitations
- Make sure that extension class is imported before its methods are used (i.e. import it in your init code).
super()can't be used in an extension class for now.- Type checkers won't understand what's going on and will complain about attributes missing.
Metadata
Release files for extensified 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| extensified-0.3.0.tar.gz | 3.6 kB | Without provenance | Details for extensified-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| extensified-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for extensified-0.3.0-py3-none-any.whl |
Total release size: 7.6 kB
Release files / extensified-0.3.0.tar.gz
| Download URL | extensified-0.3.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33fd43c01432fd6418f2b01f6d709a18fe4751bf2d3b4d5da3db3acdcb3547f9
|
|
BLAKE2b-256 checksum How to use checksums |
fad8d3b15ff0c89fa8b87edb1d3405cb201d676e7f35303ab66ea268d3df8f51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / extensified-0.3.0-py3-none-any.whl
| Download URL | extensified-0.3.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97d2a695a783ef87e605d69d4ff3d48056c7bb8dcc9c5bf9f6ec999e20f287b6
|
|
BLAKE2b-256 checksum How to use checksums |
e17bdf244b079d10f94d8a39fc04f6bbfa1d67d52205c863eef606fc732ccc37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Security for extensified 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.