Registry / devops / aspy.refactor_imports

aspy.refactor_imports

JSON →
library3.0.2pypypiunverified

Utilities for refactoring imports in Python-like syntax. Provides functions to categorize, modify, and reformat import statements. Current version 3.0.2, requires Python >=3.7. Maintained by asottile with regular updates.

pip install aspy.refactor_imports
INSTALL
IMPORT
SIG · ASPY.REFACTOR_IMPO
A
aspy.refactor_imports
devopspythonv3.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

import_module
from aspy.refactor_imports import import_module
from aspy.refactor_imports import import_module

Demonstrates categorizing import lines into types using aspy.refactor_imports.

from aspy.refactor_imports import categorize_imports, ImportType, classify_import # Example: categorize imports in a source string source = '''import os import sys from collections import OrderedDict ''' import_lines = source.splitlines() categorized = categorize_imports(import_lines, lambda x: ImportType.THIRD_PARTY) print(categorized)
Debug
Known issues
breakingVersion 3.0.0 removed deprecated functions: `import_type`, `import_descriptions`, etc. Use `categorize_imports` and `classify_import` instead.
fix
Replace calls to removed functions with new API.
affects: >=3.0.0
gotchaThe function `categorize_imports` expects a list of import strings and a classifier function returning `ImportType`. Misunderstanding the classifier signature leads to errors.
fix
Ensure the classifier takes a single import line string and returns an `ImportType` enum member.
affects: all
deprecatedThe `classify_import` function is deprecated in favor of using `categorize_imports` with a custom classifier.
fix
Use `categorize_imports` directly.
affects: <3.0.0
Upgrade
Version history
3.0.2latest on PyPI · released Jul 1, 2022
Audit
Dependencies
aspy.refactor_importsrequiredCore package
Agent activity
21 hits · last 30 days
node
20
OpenAI (training)
1
Resources
aspy.refactor_imports — pip install aspy.refactor_imports · libregistry