Skip to main content

No project description provided

Project description

codemodimportfrom

CI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codemodimportfrom-0.9.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codemodimportfrom-0.9.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file codemodimportfrom-0.9.0.tar.gz.

File metadata

  • Download URL: codemodimportfrom-0.9.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

Hashes for codemodimportfrom-0.9.0.tar.gz
Algorithm Hash digest
SHA256 df8a9b2e79801128c09a4a299327ad8cc55c38d84cc6d9d038bc2e03bf1fff9f
MD5 9a7732c99c441efdc406954fd7bb130c
BLAKE2b-256 f3e995e1cb513f27a7c0e07acfbaa8558a0563c6c9ddfcde9fc154f22e579482

See more details on using hashes here.

File details

Details for the file codemodimportfrom-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: codemodimportfrom-0.9.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

Hashes for codemodimportfrom-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fbba14cc5eeceb2117bed57148180937a26e270426429a2640bc15218e55862
MD5 d349e8dbe90c4180d27e4b335198d1f8
BLAKE2b-256 c361970b45fe6484551eb136dbfd6ba98b203c4b6874d58ad839d10b3ea916f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page