codemodimportfrom
Automatically update ImportFrom statements to "import modules, not objects".
Install
From within your project's virtual environment, install codemodimportfrom (as a dev dependency). e.g.
pip install codemodimportfrom
Usage
# Transform all ImportFrom statements in the file path/to/file.py
codemodimportfrom path/to/file.py
# Overwrite the file
codemodimportfrom path/to/file.py --write
# Transform ImportFrom statements for modules foo and bar only
codemodimportfrom path/to/file.py --module foo --module bar
# Allow object imports for typing.Optional and typing.Union
codemodimportfrom path/to/file.py --allow typing.Optional --allow typing.Union
# Allow all object imports from typing
codemodimportfrom path/to/file.py --allow "typing.*"
# Parse allow list from a .txt file (one line per allowed object import)
codemodimportfrom path/to/file.py --allow allow.txt
# Also transform module imports
# e.g. `from pydantic import dataclasses` becomes `import pydantic.dataclasses`
codemodimportfrom path/to/file.py --transform-module-imports
Caveats
- Not tested with much real world code, yet.
- Relative imports (
from . import foo) not implemented yet.
Metadata
Release files for codemodimportfrom 0.10.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 |
|---|---|---|---|---|
| codemodimportfrom-0.10.0.tar.gz | 3.2 kB | Without provenance | Details for codemodimportfrom-0.10.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| codemodimportfrom-0.10.0-py3-none-any.whl | Python 3 | none | any | Details for codemodimportfrom-0.10.0-py3-none-any.whl |
Total release size: 7.4 kB
Release files / codemodimportfrom-0.10.0.tar.gz
| Download URL | codemodimportfrom-0.10.0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b1b94d6137054af2d9a6dc1d1f51b37ef891da666588894bc5b99f6a6f8d40d
|
|
BLAKE2b-256 checksum How to use checksums |
336520e1e69a25d301b972eb66bc76a2106f0af0758972e5b8c5d0bf500c414d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.6 Darwin/22.6.0
|
Release files / codemodimportfrom-0.10.0-py3-none-any.whl
| Download URL | codemodimportfrom-0.10.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a7cebe740f692fc016297546af0d7dfd91ce25058079d5d90e892da75452ad10
|
|
BLAKE2b-256 checksum How to use checksums |
ee16ed23134dcaf1ef2fc2bf32d3da6d2b5ba14ca180ce1111e5c573d134c3a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.6 Darwin/22.6.0
|
Security for codemodimportfrom 0.10.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.