mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 22:55:08 +00:00
[red-knot] Add 'Format document' to playground (#17217)
## Summary This is more "because we can" than something we need. But since we're already building an "almost IDE" ## Test Plan https://github.com/user-attachments/assets/3a4bdad1-ba32-455a-9909-cfeb8caa1b28
This commit is contained in:
parent
12d7fad4ef
commit
3150812ac4
12 changed files with 162 additions and 27 deletions
|
@ -424,9 +424,19 @@ impl File {
|
|||
|
||||
/// Returns `true` if the file should be analyzed as a type stub.
|
||||
pub fn is_stub(self, db: &dyn Db) -> bool {
|
||||
self.path(db)
|
||||
.extension()
|
||||
.is_some_and(|extension| PySourceType::from_extension(extension).is_stub())
|
||||
self.source_type(db).is_stub()
|
||||
}
|
||||
|
||||
pub fn source_type(self, db: &dyn Db) -> PySourceType {
|
||||
match self.path(db) {
|
||||
FilePath::System(path) => path
|
||||
.extension()
|
||||
.map_or(PySourceType::Python, PySourceType::from_extension),
|
||||
FilePath::Vendored(_) => PySourceType::Stub,
|
||||
FilePath::SystemVirtual(path) => path
|
||||
.extension()
|
||||
.map_or(PySourceType::Python, PySourceType::from_extension),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue