Skip to content

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
wants to merge 5 commits into from
Closed

Conversation

connernilsen
Copy link
Contributor

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 SubConfigs 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

@facebook-github-bot
Copy link
Contributor

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:

# 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
@facebook-github-bot
Copy link
Contributor

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
Differential Revision: D72982650
Differential Revision: D72982649
Differential Revision: D73000285
Differential Revision: D73000283
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
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73000284

@facebook-github-bot
Copy link
Contributor

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants