From 9567fddf693f5c3be5ad4807fee62767542c2c90 Mon Sep 17 00:00:00 2001 From: Jane Lewis Date: Sun, 26 May 2024 10:42:48 -0700 Subject: [PATCH] `ruff server` correctly treats `.pyi` files as stub files (#11535) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fixes #11534. `DocumentQuery::source_type` now returns `PySourceType::Stub` when the document is a `.pyi` file. ## Test Plan I confirmed that stub-specific rule violations appeared with a build from this PR (they were not visible from a `main` build). Screenshot 2024-05-24 at 2 15 38 PM --- crates/ruff_server/src/session/index.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ruff_server/src/session/index.rs b/crates/ruff_server/src/session/index.rs index aa5a1efcad712..706cd96d12990 100644 --- a/crates/ruff_server/src/session/index.rs +++ b/crates/ruff_server/src/session/index.rs @@ -465,7 +465,7 @@ impl DocumentQuery { /// Get the source type of the document associated with this query. pub(crate) fn source_type(&self) -> ruff_python_ast::PySourceType { match self { - Self::Text { .. } => ruff_python_ast::PySourceType::Python, + Self::Text { .. } => ruff_python_ast::PySourceType::from(self.file_path()), Self::Notebook { .. } => ruff_python_ast::PySourceType::Ipynb, } }