Skip to content

Commit

Permalink
fix format errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Oct 22, 2024
1 parent 70d5722 commit fe5c61b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
*/

use crate::xmltype::XMLType;
use serde::{de::Visitor, Deserialize, Serialize};
use std::{error::Error, fmt, str::FromStr};
#[cfg(feature = "python")]
use pyo3::pyclass;
use serde::{de::Visitor, Deserialize, Serialize};
use std::{error::Error, fmt, str::FromStr};

/// Represents an attribute with various properties and options.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#[cfg(feature = "python")]
use crate::exporters::Templates;
#[cfg(feature = "python")]
use pyo3::prelude::*;
#[cfg(feature = "python")]
use crate::python::bindings;
#[cfg(feature = "python")]
use pyo3::prelude::*;

pub mod datamodel;
pub mod exporters;
Expand Down
2 changes: 1 addition & 1 deletion src/markdown/frontmatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
use std::collections::HashMap;

use gray_matter::{engine::YAML, Matter};
use serde::{Deserialize, Serialize};
#[cfg(feature = "python")]
use pyo3::pyclass;
use serde::{Deserialize, Serialize};

/// Represents the front matter data of a markdown file.
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
Expand Down
4 changes: 2 additions & 2 deletions src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
*/

use crate::attribute::Attribute;
#[cfg(feature = "python")]
use pyo3::pyclass;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use std::collections::BTreeMap;
#[cfg(feature = "python")]
use pyo3::pyclass;

#[skip_serializing_none]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
Expand Down
16 changes: 11 additions & 5 deletions src/python/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
use std::collections::HashMap;
use std::path::Path;

use pyo3::prelude::*;
use pyo3::types::PyType;
use crate::attribute::Attribute;
use crate::datamodel;
use crate::exporters::Templates;
use crate::markdown::frontmatter::FrontMatter;
use crate::object::{Enumeration, Object};
use pyo3::prelude::*;
use pyo3::types::PyType;

/// A Python class that wraps the `datamodel::DataModel` struct.
#[pyclass]
Expand Down Expand Up @@ -96,9 +96,15 @@ impl DataModel {
///
/// A string that represents the converted `DataModel`.
#[pyo3(signature = (template, config=None))]
fn convert_to(&mut self, template: Templates, config: Option<HashMap<String, String>>) -> String {
fn convert_to(
&mut self,
template: Templates,
config: Option<HashMap<String, String>>,
) -> String {
let config = config.unwrap_or_default();
self.model.convert_to(&template, Some(&config)).expect("Failed to convert to template")
self.model
.convert_to(&template, Some(&config))
.expect("Failed to convert to template")
}
}

Expand Down Expand Up @@ -148,4 +154,4 @@ impl Enumeration {
fn __repr__(&self) -> String {
serde_json::to_string_pretty(&self).unwrap()
}
}
}
4 changes: 3 additions & 1 deletion src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ use colored::Colorize;
use log::error;

// Basic types that are ignored in the validation process
const BASIC_TYPES: [&str; 7] = ["string", "number", "integer", "boolean", "float", "date", "bytes"];
const BASIC_TYPES: [&str; 7] = [
"string", "number", "integer", "boolean", "float", "date", "bytes",
];

/// Validator for checking the integrity of a data model.
pub struct Validator {
Expand Down
4 changes: 2 additions & 2 deletions src/xmltype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*
*/

use serde::{Deserialize, Serialize};
use std::str::FromStr;
#[cfg(feature = "python")]
use pyo3::pyclass;
use serde::{Deserialize, Serialize};
use std::str::FromStr;

/// Represents an XML type, either an attribute or an element.
#[derive(Debug, PartialEq, Clone)]
Expand Down

0 comments on commit fe5c61b

Please sign in to comment.