@@ -561,12 +561,15 @@ impl DocumentQuery {
561561 }
562562 }
563563
564- /// Generate a source kind used by the linter.
565- pub ( crate ) fn make_source_kind ( & self ) -> ruff_linter:: source_kind:: SourceKind {
564+ /// Generate a Python source kind used by the linter.
565+ pub ( crate ) fn make_python_source_kind (
566+ & self ,
567+ source_type : ruff_python_ast:: PySourceType ,
568+ ) -> ruff_linter:: source_kind:: SourceKind {
566569 match self {
567570 Self :: Text { document, .. } => ruff_linter:: source_kind:: SourceKind :: Python {
568571 code : document. contents ( ) . to_string ( ) ,
569- is_stub : ruff_python_ast :: PySourceType :: from ( self . virtual_file_path ( ) ) . is_stub ( ) ,
572+ is_stub : source_type . is_stub ( ) ,
570573 } ,
571574 Self :: Notebook { notebook, .. } => {
572575 ruff_linter:: source_kind:: SourceKind :: ipy_notebook ( notebook. make_ruff_notebook ( ) )
@@ -582,10 +585,26 @@ impl DocumentQuery {
582585 }
583586 }
584587
585- /// Get the source type of the document associated with this query.
586- pub ( crate ) fn source_type ( & self ) -> ruff_python_ast:: SourceType {
588+ /// Get the source type for linter-oriented operations.
589+ pub ( crate ) fn source_type_for_lint ( & self ) -> ruff_python_ast:: SourceType {
590+ match self {
591+ Self :: Text { settings, .. } => settings
592+ . linter
593+ . extension
594+ . get_source_type ( & self . virtual_file_path ( ) ) ,
595+ Self :: Notebook { .. } => {
596+ ruff_python_ast:: SourceType :: Python ( ruff_python_ast:: PySourceType :: Ipynb )
597+ }
598+ }
599+ }
600+
601+ /// Get the source type for formatter-oriented operations.
602+ pub ( crate ) fn source_type_for_format ( & self ) -> ruff_python_ast:: SourceType {
587603 match self {
588- Self :: Text { .. } => ruff_python_ast:: SourceType :: from ( self . virtual_file_path ( ) ) ,
604+ Self :: Text { settings, .. } => settings
605+ . formatter
606+ . extension
607+ . get_source_type ( & self . virtual_file_path ( ) ) ,
589608 Self :: Notebook { .. } => {
590609 ruff_python_ast:: SourceType :: Python ( ruff_python_ast:: PySourceType :: Ipynb )
591610 }
0 commit comments