py_import_helper/
lib.rs

1//! Python import organization library
2//!
3//! A Rust library for automatically organizing Python imports according to PEP 8.
4//! Perfect for code generation projects, it categorizes imports into standard library,
5//! third-party, and local packages, then formats them with proper spacing and ordering.
6//!
7//! # Usage
8//!
9//! ```rust
10//! use py_import_helper::ImportHelper;
11//!
12//! // Create a helper with package name for local import detection
13//! let mut helper = ImportHelper::with_package_name("mypackage".to_string());
14//!
15//! // Add custom local package prefixes
16//! helper.add_local_package_prefix("mypackage");
17//!
18//! // Collect imports using strings
19//! helper.add_import_string("from typing import Any");
20//! helper.add_import_string("from pydantic import BaseModel");
21//! helper.add_import_string("from mypackage.models import User");
22//!
23//! // Or use the builder pattern
24//! helper.add_from_import("typing", &["Optional", "List"]);
25//! helper.add_direct_import("json");
26//!
27//! // Get categorized imports
28//! let (future, stdlib, third_party, local) = helper.get_categorized();
29//! ```
30
31// Modules
32mod core;
33pub mod registry;
34pub mod types;
35
36// Utility modules (public for advanced usage)
37pub mod utils;
38
39// Re-export the main ImportHelper and key types
40pub use core::ImportHelper;
41pub use registry::PackageRegistry;
42
43// Re-export types that might be needed for advanced usage
44#[allow(unused_imports)]
45pub use types::{FormattingConfig, ImportCategory, ImportSections, ImportStatement, ImportType};
46
47// Re-export constants for external use
48#[allow(unused_imports)]
49pub use registry::constants::{COMMON_THIRD_PARTY_PACKAGES, PYTHON_STDLIB_MODULES};