classify-imports
Utilities for refactoring imports in python-like syntax.
installation
pip install classify-imports
examples
splitting an import object
>>> from classify_imports import import_obj_from_str
>>> obj = import_obj_from_str('import foo, bar, baz')
>>> [str(i) for i in obj.split()]
['import foo\n', 'import bar\n', 'import baz\n']
sorting import objects
# Or to partition into blocks (even with mixed imports)
>>> import pprint
>>> from classify_imports import import_obj_from_str, sort
>>> partitioned = sort(
[
import_obj_from_str('from classify_imports import sort'),
import_obj_from_str('import sys'),
import_obj_from_str('from pyramid.view import view_config'),
import_obj_from_str('import cached_property'),
],
)
>>> pprint.pprint(partitioned)
(
(import_obj_from_str('import sys\n'),),
(
import_obj_from_str('import cached_property\n'),
import_obj_from_str('from pyramid.view import view_config\n'),
),
(import_obj_from_str('from classify_imports import sort\n'),),
)
classify a module
>>> from classify_imports import classify_base, import_obj_from_str, Classified
>>> classify_base('__future__')
'FUTURE'
>>> classify_base('classify_imports')
'APPLICATION'
>>> classify_base('pyramid')
'THIRD_PARTY'
>>> classify_base('os')
'BUILTIN'
>>> classify_base(import_obj_from_str('import os.path').module_base)
'BUILTIN'
>>> Classified.APPLICATION
'APPLICATION'
>>> Classified.order
('FUTURE', 'BUILTIN', 'THIRD_PARTY', 'APPLICATION')
Metadata
Release files for classify-imports 4.5.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 |
|---|---|---|---|---|
| classify_imports-4.5.0.tar.gz | 4.8 kB | Without provenance | Details for classify_imports-4.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| classify_imports-4.5.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for classify_imports-4.5.0-py2.py3-none-any.whl |
Total release size: 9.9 kB
Release files / classify_imports-4.5.0.tar.gz
| Download URL | classify_imports-4.5.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83af69ba9d4d05dd15146848d7b2cfa900a8f5cc81f26693688af73e8b199497
|
|
BLAKE2b-256 checksum How to use checksums |
b5ac1223bc31ef2947227fe8c705efd005e6d06170cff33db3ccaef34ab98b69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / classify_imports-4.5.0-py2.py3-none-any.whl
| Download URL | classify_imports-4.5.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
04f37f789241f2f35cb04b63de8f77b502405bba144402a97b75542582fbdcdc
|
|
BLAKE2b-256 checksum How to use checksums |
0ed223d18e9a5047bb2b5a30b82fd89aa22b095e3347b7dc0f1dc624fa011564
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for classify-imports 4.5.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.