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
# 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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codemodimportfrom-0.6.0.tar.gz.
File metadata
- Download URL: codemodimportfrom-0.6.0.tar.gz
- Upload date:
- Size: 3.1 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 |
3e1b002dbfba7961df5b926df833d40ac278f2b192c9c4defacde3586af848c3
|
|
| MD5 |
1493178bd3f3aa9ac6d642d27f0d66df
|
|
| BLAKE2b-256 |
505a14d77200fa9cd1ca3e5e9488d05a91dda22c15a4d2b9288d2c15ded63588
|
File details
Details for the file codemodimportfrom-0.6.0-py3-none-any.whl.
File metadata
- Download URL: codemodimportfrom-0.6.0-py3-none-any.whl
- Upload date:
- Size: 4.1 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 |
8ee3ba4c5cd7c7eb32cab80fb239a79746428d6d6e34847c39cf551f65146bf7
|
|
| MD5 |
e357f17126ca61de7cf3ada5b8b0f447
|
|
| BLAKE2b-256 |
617cf0b02d25cbbde617a4f3702db517dd1923d521011ce08af0446971b6b112
|