mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
[red-knot] Add notebook support (#12338)
This commit is contained in:
parent
fe04f2b09d
commit
0c72577b5d
12 changed files with 246 additions and 53 deletions
|
@ -86,12 +86,19 @@ impl PySourceType {
|
|||
///
|
||||
/// Falls back to `Python` if the extension is not recognized.
|
||||
pub fn from_extension(extension: &str) -> Self {
|
||||
match extension {
|
||||
Self::try_from_extension(extension).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Infers the source type from the file extension.
|
||||
pub fn try_from_extension(extension: &str) -> Option<Self> {
|
||||
let ty = match extension {
|
||||
"py" => Self::Python,
|
||||
"pyi" => Self::Stub,
|
||||
"ipynb" => Self::Ipynb,
|
||||
_ => Self::Python,
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(ty)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue