-
Notifications
You must be signed in to change notification settings - Fork 134
Create SubConfig #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Create SubConfig #91
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This pull request was exported from Phabricator. Differential Revision: D73000284 |
46ae37d
to
ca45b3a
Compare
connernilsen
added a commit
to connernilsen/pyrefly
that referenced
this pull request
Apr 15, 2025
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 the `SubConfig` struct, which allows us to store `SubConfig`s in a `ConfigFile`. The main changes involve adding the field to the `ConfigFile` struct, updating `from_file()` and `validate()` to operate on sub configs in addition to the root, and adding the field to struct construction when required. The rest of the changes add tests to validate the behavior works as expected. Differential Revision: D73000284
This pull request was exported from Phabricator. Differential Revision: D73000284 |
connernilsen
added a commit
to connernilsen/pyrefly
that referenced
this pull request
Apr 15, 2025
Summary: Pull Request resolved: facebook#91 # 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 the `SubConfig` struct, which allows us to store `SubConfig`s in a `ConfigFile`. The main changes involve adding the field to the `ConfigFile` struct, updating `from_file()` and `validate()` to operate on sub configs in addition to the root, and adding the field to struct construction when required. The rest of the changes add tests to validate the behavior works as expected. Differential Revision: D73000284
ca45b3a
to
1a8ecc0
Compare
Differential Revision: D72982650
Differential Revision: D72982649
Differential Revision: D73000285
Differential Revision: D73000283
1a8ecc0
to
ffb2917
Compare
connernilsen
added a commit
to connernilsen/pyrefly
that referenced
this pull request
Apr 16, 2025
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 the `SubConfig` struct, which allows us to store `SubConfig`s in a `ConfigFile`. The main changes involve adding the field to the `ConfigFile` struct, updating `from_file()` and `validate()` to operate on sub configs in addition to the root, and adding the field to struct construction when required. The rest of the changes add tests to validate the behavior works as expected. Reviewed By: ndmitchell Differential Revision: D73000284
Summary: Pull Request resolved: facebook#91 # 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 the `SubConfig` struct, which allows us to store `SubConfig`s in a `ConfigFile`. The main changes involve adding the field to the `ConfigFile` struct, updating `from_file()` and `validate()` to operate on sub configs in addition to the root, and adding the field to struct construction when required. The rest of the changes add tests to validate the behavior works as expected. Reviewed By: ndmitchell Differential Revision: D73000284
This pull request was exported from Phabricator. Differential Revision: D73000284 |
ffb2917
to
256de02
Compare
This pull request has been merged in 977a809. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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.BaseConfig
type, which will be flattened into the mainConfigFile
type.Glob
type (pull some of the logic fromGlobs
).SubConfigs
and add them toConfigFile
, which areBaseConfigs
paired with aGlob
.SubConfig
to use (or the default), and grab the given config value from it.This Diff...
This diff creates the
SubConfig
struct, which allows us to storeSubConfig
s in aConfigFile
. The main changes involve adding the field to theConfigFile
struct, updatingfrom_file()
andvalidate()
to operate on sub configs in addition to the root, and adding the field to struct construction when required.The rest of the changes add tests to validate the behavior works as expected.
Differential Revision: D73000284