add pedantic clippy setting and fix/allow warnings (#147)
Some checks are pending
lint / pre-commit (push) Waiting to run
lint / rustfmt (push) Waiting to run
lint / clippy (push) Waiting to run
lint / cargo-check (push) Waiting to run
release / build (push) Waiting to run
release / test (push) Waiting to run
release / release (push) Blocked by required conditions
test / generate-matrix (push) Waiting to run
test / Python , Django () (push) Blocked by required conditions
test / tests (push) Blocked by required conditions
zizmor 🌈 / zizmor latest via PyPI (push) Waiting to run

This commit is contained in:
Josh Thomas 2025-05-14 18:21:43 -05:00 committed by GitHub
parent e87c917cb6
commit d677aacf7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 180 additions and 113 deletions

View file

@ -19,3 +19,6 @@ djls-dev = { workspace = true }
[dev-dependencies]
tempfile = { workspace = true }
[lints]
workspace = true

View file

@ -23,6 +23,7 @@ pub struct DjangoProject {
}
impl DjangoProject {
#[must_use]
pub fn new(path: PathBuf) -> Self {
Self {
path,
@ -64,17 +65,19 @@ impl DjangoProject {
Ok(())
}
Err(e) => {
eprintln!("Failed to import Django: {}", e);
eprintln!("Failed to import Django: {e}");
Err(e)
}
}
})
}
#[must_use]
pub fn template_tags(&self) -> Option<&TemplateTags> {
self.template_tags.as_ref()
}
#[must_use]
pub fn path(&self) -> &Path {
&self.path
}
@ -84,7 +87,7 @@ impl fmt::Display for DjangoProject {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "Project path: {}", self.path.display())?;
if let Some(py_env) = &self.env {
write!(f, "{}", py_env)?;
write!(f, "{py_env}")?;
}
Ok(())
}
@ -141,7 +144,7 @@ mod tests {
let project = DjangoProject::new(project_path.clone());
let display_str = format!("{}", project);
let display_str = format!("{project}");
assert!(display_str.contains(&format!("Project path: {}", project_path.display())));
}
}

View file

@ -96,9 +96,8 @@ impl PythonEnvironment {
}
fn from_system_python() -> Option<Self> {
let python_path = match system::find_executable("python") {
Ok(p) => p,
Err(_) => return None,
let Ok(python_path) = system::find_executable("python") else {
return None;
};
let bin_dir = python_path.parent()?;
let prefix = bin_dir.parent()?;

View file

@ -35,7 +35,7 @@ impl TemplateTags {
let library_name = if module_name.is_empty() {
"builtins".to_string()
} else {
module_name.split('.').last().unwrap_or("").to_string()
module_name.split('.').next_back().unwrap_or("").to_string()
};
tags.push(TemplateTag::new(tag_name, library_name, doc));
@ -90,7 +90,7 @@ impl TemplateTag {
&self.library
}
pub fn doc(&self) -> &Option<String> {
&self.doc
pub fn doc(&self) -> Option<&String> {
self.doc.as_ref()
}
}