import-transforms is a Python library for intercepting and transforming source code at import time. Its main use is unit-syntax, which modifies the Python syntax to support units of measure.
Usage
Transforms are defined by extending import_transforms.SourceTransform. For a small example that adds logging of every single function call, see call_log.py.
To apply a transform to future module imports:
register_module_source_transform("target_module", my_transform)
import target_module # transform applied!
The first argument is a glob-style pattern on the fully-qualified module name:
- "foo" matches just that single module.
- "foo.*" matches all sub-modules of "foo" (but not "foo" itself).
- "*" will match all modules.
As a shorthand to apply a transform to all sub-modules of your package, place this in __init__.py:
register_package_source_transform(__name__, my_transform)
TODO
- check/support bytecode cached files
Metadata
Release files for import-transforms 0.6.1
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 |
|---|---|---|---|---|
| import_transforms-0.6.1.tar.gz | 3.9 kB | Without provenance | Details for import_transforms-0.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| import_transforms-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for import_transforms-0.6.1-py3-none-any.whl |
Total release size: 8.6 kB
Release files / import_transforms-0.6.1.tar.gz
| Download URL | import_transforms-0.6.1.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d6a471d9d620e5cfe779a5819c128c2ca3154cd7dd167ef76305f2834e80b2f
|
|
BLAKE2b-256 checksum How to use checksums |
e27761fa76694f01f6ce49fb862f20f4767a479724bf41d1e63e6ed476ae014b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / import_transforms-0.6.1-py3-none-any.whl
| Download URL | import_transforms-0.6.1-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a7ca2447a5c9dc83705abb96545877178ae9a027aeac3cbe0b1d259342a64688
|
|
BLAKE2b-256 checksum How to use checksums |
b308571cb5bfed1ff3c06fe985754571e737e5ad093605676b0f08cc99dd3071
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for import-transforms 0.6.1
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.