Skip to content

Commit 7635db6

Browse files
connernilsenfacebook-github-bot
authored andcommitted
Create associated getter functions for ConfigBase
Summary: # This Feature... Over the next few diffs, we'll be implementing the functionality for sub-configs. This involves selecting configuration values from a sub-config for a matched file path, overriding the value used in the root config (if present). It will allow users with multiple projects in the same repository that should use different settings to work under the same config, type checking everything at once, and could make LSP configuration easier if we choose to emulate Pyright's approach. ## High Level Approach 1. Make all config values `Option` types. This will let us know that we need to fall back to the next sub-config or the root config, instead of taking whatever default value we find. 2. Make a `BaseConfig` type, which will be flattened into the main `ConfigFile` type. 3. Make a `Glob` type (pull some of the logic from `Globs`). 4. Create `SubConfigs` and add them to `ConfigFile`, which are `BaseConfigs` paired with a `Glob`. 5. Implement configuration resolution, which will figure out which `SubConfig` to use (or the default), and grab the given config value from it. # This Diff... This diff creates associated getter functions for `ConfigBase`, which will make the getters easy to pass around with our upcoming sub config searching functionality. Reviewed By: ndmitchell Differential Revision: D73085221 fbshipit-source-id: 27838141872c463fb6b85220f7b4a38dd8340ab3
1 parent bca4567 commit 7635db6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: pyrefly/lib/config/base.rs

+18
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,21 @@ pub struct ConfigBase {
3636
#[serde(default, flatten)]
3737
pub extras: ExtraConfigs,
3838
}
39+
40+
impl ConfigBase {
41+
pub fn get_errors(base: &Self) -> Option<&ErrorDisplayConfig> {
42+
base.errors.as_ref()
43+
}
44+
45+
pub fn get_replace_imports_with_any(base: &Self) -> Option<&[ModuleWildcard]> {
46+
base.replace_imports_with_any.as_deref()
47+
}
48+
49+
pub fn get_skip_untyped_functions(base: &Self) -> Option<&bool> {
50+
base.skip_untyped_functions.as_ref()
51+
}
52+
53+
pub fn get_ignore_errors_in_generated_code(base: &Self) -> Option<&bool> {
54+
base.ignore_errors_in_generated_code.as_ref()
55+
}
56+
}

0 commit comments

Comments
 (0)