pub struct PythonFormatter;Expand description
Python code formatter implementing language-specific conventions
Formats generated Python code to comply with:
- PEP 8 style guide
- ruff linting rules
- mypy type checking
NumPydocstring conventions
§Example
use spikard_cli::codegen::formatters::{Formatter, PythonFormatter, HeaderMetadata, Import};
let formatter = PythonFormatter::new();
let metadata = HeaderMetadata {
auto_generated: true,
schema_file: Some("schema.graphql".to_string()),
generator_version: Some("0.6.2".to_string()),
};
let header = formatter.format_header(&metadata);
assert!(header.contains("#!/usr/bin/env python3"));
assert!(header.contains("# ruff: noqa"));Implementations§
Trait Implementations§
Source§impl Clone for PythonFormatter
impl Clone for PythonFormatter
Source§fn clone(&self) -> PythonFormatter
fn clone(&self) -> PythonFormatter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PythonFormatter
impl Debug for PythonFormatter
Source§impl Default for PythonFormatter
impl Default for PythonFormatter
Source§impl Formatter for PythonFormatter
impl Formatter for PythonFormatter
Source§fn format_header(&self, metadata: &HeaderMetadata) -> String
fn format_header(&self, metadata: &HeaderMetadata) -> String
Format a file header with metadata about auto-generation Read more
Source§fn format_imports(&self, imports: &[Import]) -> String
fn format_imports(&self, imports: &[Import]) -> String
Format import/require/use statements Read more
Auto Trait Implementations§
impl Freeze for PythonFormatter
impl RefUnwindSafe for PythonFormatter
impl Send for PythonFormatter
impl Sync for PythonFormatter
impl Unpin for PythonFormatter
impl UnsafeUnpin for PythonFormatter
impl UnwindSafe for PythonFormatter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more