Make SourceKind a required parameter (#7013)

This commit is contained in:
Dhruv Manilawala 2023-09-04 13:15:59 +05:30 committed by GitHub
parent 93ca8ebbc0
commit 1067261a55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 62 additions and 60 deletions

View file

@ -10,6 +10,7 @@ use ruff::linter::{check_path, LinterResult};
use ruff::registry::AsRule;
use ruff::settings::types::PythonVersion;
use ruff::settings::{defaults, flags, Settings};
use ruff::source_kind::SourceKind;
use ruff_formatter::{FormatResult, Formatted};
use ruff_python_ast::{Mod, PySourceType};
use ruff_python_codegen::Stylist;
@ -165,6 +166,9 @@ impl Workspace {
pub fn check(&self, contents: &str) -> Result<JsValue, Error> {
let source_type = PySourceType::default();
// TODO(dhruvmanila): Support Jupyter Notebooks
let source_kind = SourceKind::Python(contents.to_string());
// Tokenize once.
let tokens: Vec<LexResult> = ruff_python_parser::tokenize(contents, source_type.as_mode());
@ -195,7 +199,7 @@ impl Workspace {
&directives,
&self.settings,
flags::Noqa::Enabled,
None,
&source_kind,
source_type,
);