@@ -121,6 +121,9 @@ impl Options {
121121 ValueSource :: File ( path) => PythonVersionSource :: ConfigFile (
122122 PythonVersionFileSource :: new ( path. clone ( ) , ranged_version. range ( ) ) ,
123123 ) ,
124+ ValueSource :: PythonVSCodeExtension => {
125+ PythonVersionSource :: PythonVSCodeExtension
126+ }
124127 } ,
125128 } ) ;
126129
@@ -140,6 +143,7 @@ impl Options {
140143 ValueSource :: File ( path) => {
141144 SysPrefixPathOrigin :: ConfigFileSetting ( path. clone ( ) , python_path. range ( ) )
142145 }
146+ ValueSource :: PythonVSCodeExtension => SysPrefixPathOrigin :: PythonVSCodeExtension ,
143147 } ;
144148
145149 Some ( PythonEnvironment :: new (
@@ -702,6 +706,10 @@ impl Rules {
702706 let lint_source = match source {
703707 ValueSource :: File ( _) => LintSource :: File ,
704708 ValueSource :: Cli => LintSource :: Cli ,
709+
710+ ValueSource :: PythonVSCodeExtension => {
711+ unreachable ! ( "Can't configure rules from the Python VSCode extension" )
712+ }
705713 } ;
706714 if let Ok ( severity) = Severity :: try_from ( * * level) {
707715 selection. enable ( lint, severity, lint_source) ;
@@ -854,6 +862,7 @@ fn build_include_filter(
854862 Severity :: Info ,
855863 "The pattern was specified on the CLI" ,
856864 ) ) ,
865+ ValueSource :: PythonVSCodeExtension => unreachable ! ( "Can't configure includes from the Python VSCode extension" ) ,
857866 }
858867 } ) ?;
859868 }
@@ -936,6 +945,9 @@ fn build_exclude_filter(
936945 Severity :: Info ,
937946 "The pattern was specified on the CLI" ,
938947 ) ) ,
948+ ValueSource :: PythonVSCodeExtension => unreachable ! (
949+ "Can't configure excludes from the Python VSCode extension"
950+ )
939951 }
940952 } ) ?;
941953 }
@@ -1497,8 +1509,11 @@ impl OptionDiagnostic {
14971509/// This is a wrapper for options that actually get loaded from configuration files
14981510/// and the CLI, which also includes a `config_file_override` option that overrides
14991511/// default configuration discovery with an explicitly-provided path to a configuration file
1512+ #[ derive( Debug , Default , PartialEq , Eq , Clone ) ]
15001513pub struct ProjectOptionsOverrides {
15011514 pub config_file_override : Option < SystemPathBuf > ,
1515+ pub fallback_python_version : Option < RangedValue < PythonVersion > > ,
1516+ pub fallback_python : Option < RelativePathBuf > ,
15021517 pub options : Options ,
15031518}
15041519
@@ -1507,8 +1522,22 @@ impl ProjectOptionsOverrides {
15071522 Self {
15081523 config_file_override,
15091524 options,
1525+ ..Self :: default ( )
15101526 }
15111527 }
1528+
1529+ pub fn apply_to ( & self , options : Options ) -> Options {
1530+ let mut combined = self . options . clone ( ) . combine ( options) ;
1531+
1532+ // Set the fallback python version and path if set
1533+ combined. environment . combine_with ( Some ( EnvironmentOptions {
1534+ python_version : self . fallback_python_version . clone ( ) ,
1535+ python : self . fallback_python . clone ( ) ,
1536+ ..EnvironmentOptions :: default ( )
1537+ } ) ) ;
1538+
1539+ combined
1540+ }
15121541}
15131542
15141543trait OrDefault {
0 commit comments