No project description provided
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file codemodimportfrom-0.10.0.tar.gz
.
File metadata
- Download URL: codemodimportfrom-0.10.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.6 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b1b94d6137054af2d9a6dc1d1f51b37ef891da666588894bc5b99f6a6f8d40d |
|
MD5 | 499b3d24830f33f2db0dbb23a991e3b4 |
|
BLAKE2b-256 | 336520e1e69a25d301b972eb66bc76a2106f0af0758972e5b8c5d0bf500c414d |
File details
Details for the file codemodimportfrom-0.10.0-py3-none-any.whl
.
File metadata
- Download URL: codemodimportfrom-0.10.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.6 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7cebe740f692fc016297546af0d7dfd91ce25058079d5d90e892da75452ad10 |
|
MD5 | b2829f4eecb8d6b6d01d8d79fe5eccca |
|
BLAKE2b-256 | ee16ed23134dcaf1ef2fc2bf32d3da6d2b5ba14ca180ce1111e5c573d134c3a4 |