Thank you for your interest in improving Pyrefly's JSON Schema definitions!
The schemas in this directory provide validation, autocomplete, and documentation for Pyrefly configuration files. When updating the schemas, it's important to keep them in sync with the actual configuration implementation.
pyrefly.toml files[tool.pyrefly] section in pyproject.tomlBoth schemas should have identical configuration options, just wrapped differently.
Update the schemas whenever:
The authoritative source for configuration options is:
crates/pyrefly_config/src/config.rs - Main config structurecrates/pyrefly_config/src/base.rs - Base config optionswebsite/docs/configuration.mdx - User-facing documentationAlways verify your changes against these sources.
When adding a new configuration option, update pyrefly.json. pyproject-tool-pyrefly.json contains the definition for the [tool.pyrefly] section in a pyproject.toml file, so it likely won't need to be updated.
string, boolean, array, object, etc.python-platform or untyped-def-behavior^\d+(\.\d+)?(\.\d+)?$required array for mandatory fieldsAdd examples of the new configuration option to the test files:
test-pyrefly.toml - Examples for pyrefly.tomltest-pyproject.toml - Examples for pyproject.tomlRun the validation script to ensure the schemas are correct:
python schemas/validate_schemas.py
This script validates the test configuration files against the schemas.
If you're adding a new configuration option, also update:
schemas/README.md - If the change affects how users interact with schemaswebsite/docs/configuration.mdx - User-facing documentation (if not already done)"property-name": { "description": "Clear description of what this does", "type": "string|boolean|array|object|number", "default": <default-value>, "enum": ["value1", "value2"], // For fixed set of values "pattern": "regex", // For string validation "items": {...}, // For array element types "properties": {...} // For object properties }
python-version, not python_version"new-option-name": { "description": "Whether to enable the new feature. Default is false.", "type": "boolean", "default": false }
"new-mode": { "description": "The mode to use for the new feature.", "type": "string", "enum": ["strict", "lenient", "off"], "default": "lenient" }
"new-patterns": { "description": "List of glob patterns for the new feature.", "type": "array", "items": { "type": "string" }, "default": [] }
The validate_schemas.py script validates test files against schemas:
# Install dependencies (if not already installed) pip install jsonschema toml # Run validation python schemas/validate_schemas.py
Add test cases to test-pyrefly.toml and test-pyproject.toml that exercise your new configuration option.
If you have questions about updating the schemas: