This directory contains JSON Schema definitions for Pyrefly configuration files.
JSON Schema for pyrefly.toml configuration files. This schema provides validation, autocomplete, and documentation for all Pyrefly configuration options when editing pyrefly.toml files.
Schema URL: https://pyrefly.org/schemas/pyrefly.json
JSON Schema for the [tool.pyrefly] section in pyproject.toml files. This schema provides the same validation and autocomplete features as the pyrefly.json schema, but formatted for use within pyproject.toml files.
Schema URL: https://pyrefly.org/schemas/pyproject-tool-pyrefly.json
VS Code will automatically detect and use these schemas when you have the appropriate extensions installed:
-
For pyrefly.toml files:
- Install the "Even Better TOML" extension
- Add the following to your
settings.json:
{ "evenBetterToml.schema.associations": { "pyrefly.toml": "https://pyrefly.org/schemas/pyrefly.json" } } -
For pyproject.toml files:
- The "Even Better TOML" extension automatically supports
[tool.pyrefly]sections - No additional configuration needed
- The "Even Better TOML" extension automatically supports
PyCharm automatically recognizes TOML schemas. You can configure schema mappings in:
- Settings → Languages & Frameworks → Schemas and DTDs → JSON Schema Mappings
Most modern editors with TOML support can use JSON Schemas. Consult your editor's documentation for configuring custom schema mappings.
During development, you can reference the local schema files:
For pyrefly.toml:
Add a comment at the top of your pyrefly.toml:
# yaml-language-server: $schema=./schemas/pyrefly.jsonFor pyproject.toml:
Add a comment in the [tool.pyrefly] section:
[tool.pyrefly]
# yaml-language-server: $schema=./schemas/pyproject-tool-pyrefly.jsonThe schemas provide:
- Validation: Ensures your configuration follows the correct structure and types
- Autocomplete: Suggests available configuration options as you type
- Documentation: Shows descriptions and default values for each configuration option
- Type Checking: Validates that values match expected types (strings, arrays, booleans, etc.)
- Enum Validation: Ensures enum values (like
python-platformoruntyped-def-behavior) are valid
When adding new configuration options to Pyrefly:
- Update the schema files in this directory
- Ensure the schema matches the actual config structure in
crates/pyrefly_config/ - Update the configuration documentation in
website/docs/configuration.mdx - Test the schema with sample configs
These schemas can be submitted to SchemaStore to provide automatic validation in all compatible editors without manual configuration.
To submit:
- Fork the SchemaStore repository
- Add the schema files to the
src/schemas/json/directory - Update the
src/api/json/catalog.jsonto register the schemas - Submit a pull request
For more information, see the SchemaStore contribution guide.