Skip to content

Commit

Permalink
ruff server correctly treats .pyi files as stub files (#11535)
Browse files Browse the repository at this point in the history
## 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).

<img width="1066" alt="Screenshot 2024-05-24 at 2 15 38 PM"
src="https://github.com/astral-sh/ruff/assets/19577865/cd519b7e-21e4-41c8-bc30-43eb6d4d438e">
  • Loading branch information
snowsignal committed May 26, 2024
1 parent ab6d9d4 commit 9567fdd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/ruff_server/src/session/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down

0 comments on commit 9567fdd

Please sign in to comment.