abs-imports
A pre-commit hook to automatically convert relative imports to absolute.
Installation
pip install abs-imports
Usage as a pre-commit hook
See pre-commit for instructions
Sample .pre-commit-config.yaml:
- repo: https://github.com/MarcoGorelli/abs-imports
rev: v0.2.1
hooks:
- id: abs-imports
Command-line example
$ cat mypackage/myfile.py
from . import __version__
$ abs-imports mypackage/myfile.py
$ cat mypackage/myfile.py
from mypackage import __version__
If your package follows the popular ./src layout, you can pass your application directories via --application-directories, e.g.
$ cat src/mypackage/myfile.py
from . import __version__
$ abs-imports src/mypackage/myfile.py --application-directories src
$ cat src/mypackage/myfile.py
from mypackage import __version__
Multiple application directories should be comma-separated, e.g. --application-directories .:src. This is the same as in reorder-python-imports.
See also
Check out pyupgrade, which I learned a lot from when writing this.
Metadata
Release files for abs-imports 0.2.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 |
|---|---|---|---|---|
| abs_imports-0.2.1.tar.gz | 3.7 kB | Without provenance | Details for abs_imports-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| abs_imports-0.2.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for abs_imports-0.2.1-py2.py3-none-any.whl |
Total release size: 7.6 kB
Release files / abs_imports-0.2.1.tar.gz
| Download URL | abs_imports-0.2.1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa44cfe1d84c008ab1052cece54b912f12cdd5234ea502993ae4741dae1d435b
|
|
BLAKE2b-256 checksum How to use checksums |
1a534871898128bed1556ea73cc23baf32ee70368d937fc999651154546e1383
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
|
Release files / abs_imports-0.2.1-py2.py3-none-any.whl
| Download URL | abs_imports-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
ded7a124df334c78b784c30fae8ad13147cd9c833c633b8ba163cdffe79e434b
|
|
BLAKE2b-256 checksum How to use checksums |
71b942b6d51be39ce3bdde99864a8afa07dd22fc4cac745b6fe1f8f8bd86c3f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
|
Security for abs-imports 0.2.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.