Skip to content

Commit

Permalink
Make build system optional
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed May 24, 2023
1 parent 477cf65 commit 1a05901
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/ruff/src/pyproject_toml.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::Result;
use pyproject_toml::PyProjectToml;
use pyproject_toml::{BuildSystem, Project};
use ruff_text_size::{TextRange, TextSize};
use serde::{Deserialize, Serialize};

use ruff_diagnostics::Diagnostic;
use ruff_python_ast::source_code::SourceFile;
Expand All @@ -9,6 +10,16 @@ use crate::message::Message;
use crate::rules::ruff::rules::InvalidPyprojectToml;
use crate::IOError;

/// Unlike [pyproject_toml::PyProjectToml], in our case `build_system` is also optional
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
struct PyProjectToml {
/// Build-related data
build_system: Option<BuildSystem>,
/// Project metadata
project: Option<Project>,
}

pub fn lint_pyproject_toml(source_file: SourceFile) -> Result<Vec<Message>> {
let err = match toml::from_str::<PyProjectToml>(source_file.source_text()) {
Ok(_) => return Ok(Vec::default()),
Expand Down

0 comments on commit 1a05901

Please sign in to comment.