Pyrefly Configuration
Pyrefly has a configuration system that allows you to customize your Pyrefly runs without having to specify all of your arguments on the command line.
Configurations can be specified in a TOML file at the root of
your project (or elsewhere, as long as the path-based config options point to the right place) named
pyrefly.toml, with all configuration options in the top-level of the document.
You can also specify a configuration in a pyproject.toml under a [tool.pyrefly]
section. Other config names can be used when explicitly passing in the config file
name with the --config/-c flag, but they will not be automatically found by
Configuration Finding.
Both absolute and config-relative paths are supported.
The Bazel integration does not read these configuration files; configure its aspect instead.
Extending a Configuration
Use extends to build one configuration on another without duplicating settings.
The path may refer to a pyrefly.toml, another TOML configuration file, or a
pyproject.toml containing [tool.pyrefly].
# pyrefly.toml generated by an environment tool
extends = "pyproject.toml"
search-path = [".generated"]
site-package-path = [".venv/lib/python3.13/site-packages"]
Pyrefly loads the base configuration first, then applies settings from the
extending file. Explicit child values replace inherited scalar and list values;
tables merge by key, so a child [errors] table can override individual error
codes. Multiple levels of inheritance are supported. Relative paths are resolved
against the configuration file that declares them, and an inheritance cycle or
an invalid base configuration is an error.
extends does not change configuration finding:
Pyrefly still selects one nearby configuration file before loading its base.
Unconfigured projects
On the command line, when no pyrefly.toml or [tool.pyrefly] section governs the file being checked, Pyrefly automatically selects a synthesized configuration:
- If a
mypy.ini,pyrightconfig.json, or[tool.mypy]/[tool.pyright]/[tool.basedpyright]section inpyproject.tomlis found nearby, Pyrefly migrates it in memory and uses the resulting settings (the same migrationpyrefly initwould commit to disk). - If no migratable configuration is found, or migration fails, Pyrefly uses the basic preset. This enables only high-confidence error kinds (syntax errors, missing imports, division by zero, etc.); other diagnostics are silenced.
This automatic selection behavior is not a preset, so auto is not a valid value for preset or --preset. For the IDE equivalent, including how to override automatic selection, see python.pyrefly.typeCheckingMode.
Want full type-check squiggles by default? Run pyrefly init to create a pyrefly.toml (or update pyproject.toml).
For exactly which incumbent settings that migration preserves, see the mypy config mapping and the Pyright config mapping.
Simple Configuration Example
Here's an example of a simple config. To see more complex examples,
including in a pyproject.toml, look at
Example Configurations, which show Pyrefly's default
config, as well as other ways you can set your configuration.
# set the directory Pyrefly will search for files to type check
project-includes = [
"a", "b/c/d", "e"
]
# manually set the `sys.platform` Pyrefly will assume when type checking
python-platform = "linux"
# a table mapping error codes to an `is-enabled` boolean
[errors]
# disable `bad-assignment` errors
bad-assignment = false
# disable `bad-return` errors
bad-return = false
Precedence in Options
Configuration options are selected in the following order
- CLI flags
- Examples:
--project-excludes <value>,--python-version <value>
- Examples:
- Configuration options
- Examples: (in a
pyrefly.toml)project-excludes = <value>,python-version = <value>
- Examples: (in a
- Pyrefly defaults
- See Default
pyrefly.tomlfor the default values used
- See Default
Type Checking Modes
Pyrefly has two different modes it can run in when type checking your project, which correspond to different but useful ways we expect most people to interact with Pyrefly:
- Project mode: attempt to load a config, falling back to Pyrefly's default config when
none can be found, and type check using that one config. This involves getting the
project-includesandproject-excludesfrom the file, expanding the patterns, and type checking on those files.- Project mode is used whenever no paths to a file are provided with the CLI invocation.
- A directory given in the CLI invocation, such as
pyrefly check packages/a, also runs project mode, limited to that directory: Pyrefly finds the config from the directory instead of the current working directory, and checks only the files in that project, filtered to that directory. Directories with different configs are different projects, and one run checks all of them: each file belongs to the given project whose config root is its nearest ancestor, and is checked once, with that config. A given directory is checked even ifproject-excludesexcludes it: an exclude that matches the directory, or one of its parents, does not apply. The other excludes still apply to the files under it, such as**/generated. Pass--force-excludeto skip a given directory that the excludes match instead.
- Per-file or Single-file mode: when given files (and optionally
--project-excludes) during a CLI invocation, find the relevant config file for each file listed.project-includesandproject-excludesare ignored from the config file, but it is used for all remaining config options. Files given with a directory also run single-file mode.- A directory with no config, or whose config uses a build system, is checked in single-file mode.
Pyrefly expands a glob, such as pyrefly check 'packages/*', to the directories and Python
files that it matches, the same as a shell does. Each directory and file is then checked as if
it was given on its own, so quotes around a glob do not change the result, except that a glob
matches no files that are not Python files, and a shell passes them to Pyrefly.
Configuration Finding
In both project checking mode and single-file checking mode (see Type Checking Modes for more info), we attempt to find a project root from which to check each file, both for reading config options and for import resolution. The project root is typically the directory containing the configuration file. More precisely:
- If a configuration file is provided with
-c/--config, we use the directory the file is located in as the directory to check. - If no configuration file is passed, we perform an upward file search from the 'start location' to the filesystem root,
looking in each directory for any of the following files:
pyrefly.toml,pyproject.toml,setup.py,mypy.ini, andpyrightconfig.json. If we find one, we use the directory it's found in as the containing directory. - If no configuration file is found, we will still attempt to resolve imports by walking up the tree looking for a matching import. For example: when
importing
from a.b.c import q, if our project structure looks like/x/y/z/a/b/c, we can walk up the components ofa.b.cto find a root at/x/y/z.
pyrefly.toml and the [tool.pyrefly] section of pyproject.toml are parsed as native Pyrefly configuration. In an unconfigured project, mypy.ini, pyrightconfig.json, and the [tool.mypy] / [tool.pyright] sections of pyproject.toml may also be parsed and migrated in memory. Other files found during the search only mark the project root for import resolution.
For project checking mode, the 'start location' is current working directory. For single-file checking mode, the start location is the directory containing each file to be type checked, and we find the config for each file matched by the pattern provided.
The language server finds a configuration separately for each source file because one session can serve multiple projects. The language server also runs the search for each imported file, but a file found through the importer's site package path resolves its imports in the importer's Python environment. The per-file search can produce different IDE and project-mode CLI results. See IDE configuration selection for details and ways to configure external source trees.
If a pyrefly.toml is found, it is parsed and used for type checking, and will
return an error to the user on invalid types, syntax, values, or unknown config options.
If a pyproject.toml with [tool.pyrefly] is found, Pyrefly parses and uses that section. The same errors are returned as when loading an invalid pyrefly.toml. Without [tool.pyrefly], Pyrefly migrates [tool.mypy], [tool.pyright] or [tool.basedpyright] in memory if present; otherwise it uses the basic preset.
Providing a Config in Single-File Mode
Providing -c/--config in single-file checking mode disables the upward file search for config
files. All options are read from the provided config file except project-includes and
project-excludes, which are ignored.
Configuration Options
The following section lists all recognized options that can be specified in a config
file or pyproject.toml Pyrefly config section.
project-includes
The glob patterns used to describe which files to type check, typically understood as user-space files.
This does not specify
Import Resolution priority or the path an
import should be resolved from. See search-path instead.
- Type: list of filesystem glob patterns
- Default:
["**/*.py*"] - Flag equivalent:
FILES...argument - Equivalent configs:
includein Pyright,files/modules/packagesin mypy - Notes:
- When overridden by passing in
FILES..., we do not consult the relevant config file for what to use forproject-excludes. Ifproject-excludesshould not use the default value, override it with the flag as well. This is because if multiple configs are loaded that conflict withproject-includes, determining how to resolve checkable files gets complicated, and might become confusing to anyone attempting a type check if they're unaware of all the configs that will be used in the type check. Also, we get into a chicken-and-egg problem, where we don't know which files to exclude until we load all the configs we'll need, which requires loading all files, and imposes a large performance burden. - When a
project-includespattern does not match any files, we will return an error. - If you get an error about no matches for a directory when passing a glob as a CLI argument, try wrapping the glob in quotes to prevent eager shell glob expansion.
- When overridden by passing in
project-excludes
The glob patterns used to describe which files to avoid
type checking as way to filter files that match project-includes,
but we don't want to type check.
The default value is appended to your project-excludes unless disable-project-excludes-heuristics
is set. See disable-project-excludes-heuristics to fully replace
or remove project-excludes.
-
Type: list of filesystem glob patterns
-
Default:
["**/node_modules", "**/__pycache__", "**/venv/**", "**/.[!/.]*/**"]+ anything in yoursite-packages-path(even from the interpreter) unless it would exclude items in yoursearch-path. -
Flag equivalent:
--project-excludes, which replacesproject-excludes.--extend-project-excludesadds patterns toproject-excludesinstead.--force-excludeapplies the excludes to the paths given in the CLI invocation too. How the flags apply to each kind of check:Flag pyrefly checkpyrefly check dirpyrefly check file.pyNone The config's project-excludesThe config's project-excludes, except the ones that matchdirThe default excludes. The config's project-excludesare not used--project-excludes XXreplaces the config'sproject-excludesXreplaces the config'sproject-excludes. AnXthat matchesdirdoes not applyXreplaces the default excludes. A file thatXmatches is not checked--extend-project-excludes XXis added to the config'sproject-excludesXis added to the config'sproject-excludes. AnXthat matchesdirdoes not applyXis added to the default excludes. A file thatXmatches is not checked--force-excludeNo effect diris skipped if the excludes match itfile.pyis skipped if theproject-excludesof its config match it -
Equivalent configs:
excludein Pyright and mypy -
Notes:
- While not explicitly part of
project-excludes, there are several patterns that are filtered out of type checked files at our glob-implementation layer.- Dotfiles (any files that begin with a dot (
.<stuff>) - Any files that don't end in
.pyor.pyi - Your
site-packages-path(including paths queried from the interpreter)
- Dotfiles (any files that begin with a dot (
- It is an error if no files are returned from any
project-includesbecause they are filtered out byproject-excludesentries. We differentiate between an error from aproject-includesthat doesn't match any files, and an error from allproject-includesgetting filtered byproject-excludes. - When overridden by passing in
FILES..., we do not consult the relevant config file for what to use forproject-excludes. Ifproject-excludesshould not use the default value, override it with the flag as well. See reasoning inproject-includesnotes. - Your
site-packages-pathis added to yourproject-excludesautomatically. If you are trying to perform type checking on a dependency in yoursite-packages-path(i.e.cd <site-packages-path>/some_dependency && pyrefly check), we recommend you pull and set up your dependency from GitHub, but you can achieve this on files in yoursite-packages-pathby settingsite-packages-path = []in your config. --exclude-scriptsalso skips the PEP 723 scripts (files with a# /// scriptblock) that Pyrefly finds in the project or in the given directories, and still checks the files that you give explicitly. A script runs in its own environment, souv check --type-checker pyreflypasses--exclude-scriptsand checks a script withuv check --script.
- While not explicitly part of
disable-project-excludes-heuristics
By default, Pyrefly includes several items in your project-excludes
(see project-excludes for the default values). These items are path patterns we've
determined rarely have files that should be type checked, but can require a very long
time to crawl while enumerating files, or contain third-party code that you likely
don't care about errors in. When specifying project-excludes, we always append
these defaults to whatever is specified by CLI or in your configuration.
Sometimes, these preselected settings can interfere with your project's setup.
disable-project-excludes-heuristics lets you start from scratch, setting that default to [],
so you can fully specify your project-excludes in case we get it wrong.
- Type:
bool - Default:
false - Flag equivalent:
--disable-project-excludes-heuristics
coverage
Include/exclude overrides used only by the pyrefly coverage commands, for when the set of
files to report coverage on differs from the set of files to type check (e.g. to skip tests or
vendored code). coverage.includes takes precedence over project-includes
and coverage.excludes over project-excludes; each falls back to the
project setting when unset.
- Type: table with
includesandexcludeskeys, each a list of filesystem glob patterns - Default:
project-includes/project-excludes - Flag equivalent: none, though
--project-excludestakes precedence overcoverage.excludes, and--extend-project-excludesadds tocoverage.excludes - Notes:
- Like the project globs, these are not consulted when passing in
FILES.... coverage.excludesgets the same default excludes appended asproject-excludesdoes, unlessdisable-project-excludes-heuristicsis set.
- Like the project globs, these are not consulted when passing in
search-path
A file path describing the roots from which imports should be
found and imported from (including modules in project-includes). This takes
the highest precedence in import order,
before typeshed and site-packages-path. When a project-includes
type checked file is imported by another type checked file, we check all search roots to
determine how to import it.
- Type: list of directories specifying the root
- Default: import root
- Flag equivalent:
--search-path - Equivalent configs:
extraPathsin Pyright,mypy_pathin mypy - Notes:
- The language server selects a configuration for each imported file separately from
resolving the import through
search-path. See IDE configuration selection for details. - We automatically apply some heuristics to improve your experience, especially
when no configuration is provided. See
disable-search-path-heuristicsto disable this behavior, and Search Path Heuristics for the additional paths we add to yoursearch-path. - Libraries should not be listed here, since they may override
typeshedvalues for your whole project, and have different import semantics with respect to typing. See Import Resolution for more information about how modules are imported.
- The language server selects a configuration for each imported file separately from
resolving the import through
disable-search-path-heuristics
Disable any search path heuristics/additional search path behavior that Pyrefly will attempt to do for you. This can be useful if Pyrefly is picking up the wrong import paths for your project, for example, if you have multiple projects in the same directory or use a monorepo setup with the import root outside of the directory your configuration is defined in.
See Search Path Heuristics for more information on the search paths that are automatically added, and are affected by this flag. For more information on import resolution in general see the import resolution docs.
- Type: bool
- Default: false
- Flag equivalent:
--disable-search-path-heuristics - Equivalent configs: none
- Notes
- To see what search path we find for your a given file in your project, or
your project overall, you can run
pyrefly dump-config [<file>...].
- To see what search path we find for your a given file in your project, or
your project overall, you can run
Search Path Heuristics
Pyrefly adds extra search paths to your configuration behind-the-scenes to handle
the most common ways of setting up and configuring your project, on top of any
search-path entries you may pass in through the CLI or
set in your config.
The three heuristics that are currently supported are:
- Adding your import root to the end of your search path. Your import root is
a
src/directory in the same directory as a config file, the parent directory containing your config file if there's an__init__.pyor__init__.pyipresent or the config file's directory itself if none of the previously mentioned directories or files can be found. See Configuration Finding for more information on what we'll find as a config file. - If no Pyrefly config is present and a
src/layout is inferred, adding the project root as a lower-precedence fallback path. This lets modules under a siblingtests/directory import each other without changing the canonical names of modules undersrc/. - If no project root can be inferred, each directory from the given file to
/will be added as a fallback search path.
See more on how Pyrefly does import resolution.
enable-fallback-search-path
When enabled, Pyrefly resolves an otherwise-unresolved import by searching each
directory from the importing file up to the directory that contains your
config, using the first match it finds. Directories that belong to a regular
package (that is, contain an __init__.py or __init__.pyi) are skipped, since
they cannot be import roots without truncating the package's module names. This is a best-effort way to make
imports resolve when a module is importable relative to one of its parent
directories but that directory isn't listed in search-path.
- Type: bool
- Default: false
- Flag equivalent:
--enable-fallback-search-path - Equivalent configs: none
- Notes:
- The fallback is only consulted after the search path, typeshed, and the site package path all fail to find the module, including as a namespace package.
- Has no effect when
disable-search-path-heuristicsistrue— that flag suppresses all fallback-path consumption. - The search is bounded by the config root, so it cannot escape the project.
- To see the search path Pyrefly resolves for a given file, run
pyrefly dump-config <file>.
site-packages-path
A file path describing a root from which imports should
be found and imported from. This takes the lowest priority in import
resolution, after search-path and typeshed.
See more on how Pyrefly does import resolution.
The legacy config keys site-package-path and site_package_path, and the CLI flag
--site-package-path, remain supported as aliases for backward compatibility.
- Type: list of directories
- Default: Pyrefly adds the
typings/directory in the project root if it exists. Pyrefly then adds entries from Environment Autoconfiguration if the query succeeds. - Flag equivalent:
--site-packages-path - Equivalent configs: none
- Notes:
- When environment auto-configuration is on, Pyrefly adds entries from the interpreter
after user-specified
site-packages-pathentries. The interpreter entries can include paths thatPYTHONPATHadds tosys.path. - Ideally, this should not be set manually, unless you're using a venv, running one-off tests, testing specific behavior, or having trouble with Environment Autoconfiguration. Setting this explicitly, especially when not using a venv, will make it difficult for your configuration to be reused between different systems and platforms.
- If you're running into problems with editable installations in your project, please read up on editable installs with static analysis tools.
- When environment auto-configuration is on, Pyrefly adds entries from the interpreter
after user-specified
python-platform
The value used with conditions based on type checking
against
sys.platform
values.
- Type: string or list of strings
- Default: result from Environment Autoconfiguration, or "linux" if the Python interpreter cannot be queried
- Flag equivalent:
--python-platform, which can be passed multiple times - Equivalent configs:
pythonPlatformin Pyright,platformin mypy
Use python-platform = "all" to avoid pruning platform-specific branches, or
provide a list such as python-platform = ["linux", "win32"] to type check
branches that may run on any of those platforms. On the CLI, pass
--python-platform once per platform.
python-version
The value used with conditions based on type checking
against
sys.version
values. The format should be <major>[.<minor>[.<micro>]], where minor and
micro can be omitted to take the default positional value. The minimum supported
version is 3.5.
- Type: string of the format
<major>[.<minor>[.<micro>]] - Default: result from Environment Autoconfiguration, or
3.13.0if the Python interpreter cannot be queried - Flag equivalent:
--python-version - Equivalent configs:
pythonVersionin Pyright,python_versionin mypy
conda-environment
The name of the Conda environment to query when attempting to autoconfigure
Python environment values (site-packages-path, python-platform, python-version).
See the Environment Autoconfiguration section for more
information. We query Conda with conda info --envs, then find the environment's interpreter.
We will query Conda for information about this environment, even when it's not sourced,
unless --python-interpreter-path, --fallback-python-interpreter-name, or
--conda-environment is passed on the command line.
conda-environment, python-interpreter-path, python-interpreter-find-command,
fallback-python-interpreter-name, and skip-interpreter-query are mutually exclusive.
- Type: string of existing Conda environment name
- Default: none
- Flag equivalent:
--conda-environment - Equivalent configs: none
- Notes:
- This enables the use of a non-local but customizable global environment without having to hard-code a path, which is not preferable on a shared project.
python-interpreter-path
The Python interpreter to query when attempting to autoconfigure
Python environment values (site-packages-path, python-platform, python-version).
See the Environment Autoconfiguration section for more information.
conda-environment, python-interpreter-path, python-interpreter-find-command,
fallback-python-interpreter-name, and skip-interpreter-query are mutually exclusive.
- Type: path to executable
- Default:
$(which python3), then$(which python), or none - Flag equivalent:
--python-interpreter-path - Equivalent configs:
python_executablein mypy - Notes:
- This executes the value present in the
python-interpreter-pathfield without any checks. It could be a security risk if yourpython-interpreter-pathis an arbitrary executable. - If you don't have a Python interpreter installed on your machine, we'll output an
error letting you that we couldn't appropriately configure your environment.
Configure
skip-interpreter-queryto skip the check and avoid the error.
- This executes the value present in the
NOTE: Ideally, this should not be set manually, unless you're using a venv, running one-off tests, testing specific behavior, or having trouble with Environment Autoconfiguration. Setting this explicitly, especially when not using a venv, will make it difficult for your configuration to be reused between different systems and platforms.
python-interpreter-find-command
A command that prints the path of the Python interpreter Pyrefly should query. Configure it as an array containing the program followed by its arguments. Pyrefly runs the program directly from the configuration file's directory; it does not invoke a shell. The command must succeed and print exactly one non-empty line. A relative path is resolved from the configuration file's directory.
python-interpreter-find-command = ["poetry", "env", "info", "-e"]
For workflows that require shell features, invoke the shell explicitly, for example
["sh", "-c", "eval \"$(direnv export bash)\"; command -v python"]. On Windows, use the
equivalent cmd /C or PowerShell command.
conda-environment, python-interpreter-path, python-interpreter-find-command,
fallback-python-interpreter-name, and skip-interpreter-query are mutually exclusive.
- Type: array of strings containing a program and its arguments
- Default: none
- Flag equivalent: none
- Equivalent configs: none
- Notes:
- This executes the configured program without checking whether it is trusted. Review project configuration before running Pyrefly in an untrusted checkout.
fallback-python-interpreter-name
The Python interpreter, available on your $PATH, to use. Pyrefly will perform
which <your command>, and automatically fill in python-interpreter-path for you with
the found path. Pyrefly will automatically search for python3 and python on your
path when this option and python-interpreter-path are unset if
skip-interpreter-query = false,
so this should primarily be used when you have a non-standard Python executable you want to
use.
conda-environment, python-interpreter-path, python-interpreter-find-command,
fallback-python-interpreter-name, and skip-interpreter-query are mutually exclusive.
- Type: string of command to use
- Default:
python3, thenpython, or none - Flag equivalent:
--fallback-python-interpreter-name - Notes:
- This executes the value present in the
fallback-python-interpreter-namefield without any checks. It could be a security risk if yourfallback-python-interpreter-nameis an arbitrary executable. - If you don't have a Python interpreter installed on your machine, we'll output an
error letting you that we couldn't appropriately configure your environment.
Configure
skip-interpreter-queryto skip the check and avoid the error.
- This executes the value present in the
skip-interpreter-query
Skip querying any interpreters and do not do any
Environment Autoconfiguration. This means that
Pyrefly will take hard-coded defaults for python-version
and python-platform, and will use an empty
site-packages-path. It's likely you'll want to override
these to match the environment you'll be running in.
conda-environment, python-interpreter-path, python-interpreter-find-command,
fallback-python-interpreter-name, and skip-interpreter-query are mutually exclusive.
- Type: bool
- Default:
false - Flag equivalent:
--skip-interpreter-query
typeshed-path
Override the version of typeshed that's being used for type checking. The provided path should point to the root of typeshed.
Typeshed contains the type information for Python's
standard library, which Pyrefly uses for type checking and resolving both the most basic
types (like object, str, ...) and types/type signatures from stdlib modules.
Pyrefly reads stdlib/VERSIONS to hide standard library modules that do not exist on the
configured python-version. A typeshed supplied here is filtered by its
own stdlib/VERSIONS, not the bundled one, since it replaces Pyrefly's standard library
rather than adding to it. A module that file declares removed will not fall back to Pyrefly's
bundled stub, though it can still resolve from an installed package on the
site-packages-path.
A typeshed with no stdlib/VERSIONS — such as one produced by materializing Pyrefly's bundled
stubs — is not version-filtered at all, and Pyrefly logs a warning saying so.
- Type: path to typeshed
- Default: none (resolves to bundled typeshed)
- Flag equivalent:
--typeshed-path
baseline
Path to a baseline JSON file for comparing type errors. Errors matching the baseline are suppressed, so only newly-introduced errors are reported. This is useful when introducing type checking to a project for the first time, or when rolling out changes that would otherwise produce many new errors at once.
To generate (or re-generate) the baseline file, run:
pyrefly check --baseline="<path to baseline file>" --update-baseline
See the Error Suppressions docs for more details on how baseline files work.
- Type: path to a JSON file
- Default: none (no baseline)
- Flag equivalent:
--baseline - Notes:
baselineis a project-level setting and cannot be overridden insub-configsections.- Errors suppressed by the baseline file are still shown in the IDE.
baseline-matching-mode
Controls how diagnostics are matched against baseline entries. "column"
matches the file, error kind, and starting column. "concise-description"
matches the file, error kind, and concise description. "column-ordered" matches the
same fields as "column", but compares each file's diagnostics against its baseline
rows as an ordered sequence rather than as a set.
baseline-matching-mode = "concise-description"
- Type:
"column"|"concise-description"|"column-ordered" - Default:
"column" - Flag equivalent: none
- Notes:
baseline-matching-modeis a project-level setting and cannot be overridden insub-configsections.- There is intentionally no CLI equivalent because the matching mode is a property of the checked-in baseline and must be consistent for all users.
- After changing modes, regenerate a baseline that does not contain the new
mode's required field with
pyrefly check --update-baseline. - Under
"column"and"concise-description"a single entry suppresses any number of diagnostics that match it, so adding another occurrence of an already-baselined diagnostic reports nothing."column-ordered"aligns each file's diagnostics against its rows, so a new diagnostic is reported at the line where it was added rather than at some later line sharing its key, and the number of suppressed diagnostics cannot grow without running--update-baseline. In exchange, a baseline under"column-ordered"needs updating more often, and moving code so that two diagnostics swap places can report one of them as new. - Because the order of rows within a file is part of the comparison, do not
re-sort a
"column-ordered"baseline by hand.--update-baselinewrites the rows in source order. Baselines written by Pyrefly 0.49 or earlier can list diagnostics that share a position in a different order, which"column-ordered"would report as new, so regenerate those withpyrefly check --update-baselineafter switching. - A
"column-ordered"baseline records themin-severitythreshold it was written with, and diagnostics below it take no part in the comparison, even if the threshold changes between runs. A baseline without a recorded threshold, such as one written under another mode, can be used as is: every diagnostic then takes part. That only makes a difference when diagnostics with the same file, error kind, and column have different severities, whichtype-ignore-unknown-tag-behavior= "downgrade-to-warning"can cause. There, a downgraded warning can take the place of a baselined error, which is then reported as new. If you use that setting, runpyrefly check --update-baselineafter switching to"column-ordered".
baseline-format
Controls how much information --update-baseline writes for each baseline
entry. "full" writes all baseline metadata. "minimal" writes only the file,
error kind, and the field required by baseline-matching-mode.
baseline-format = "minimal"
- Type:
"full"|"minimal" - Default:
"full" - Flag equivalent: none
- Notes:
baseline-formatis a project-level setting and cannot be overridden insub-configsections.- There is intentionally no CLI equivalent so every baseline update uses the same format, avoiding conflicting rewrites.
baseline-error-level
The maximum severity of diagnostics that match the baseline. When unset, matched
diagnostics are suppressed from CLI output. Set this to "hint", "info", "warn",
or "error" to report matched diagnostics at the lower of their own severity and this
level. Reported matches follow the normal min-severity filtering and
exit-status behaviour.
baseline = "baseline.json"
baseline-error-level = "warn"
- Type:
"ignore"|"hint"|"info"|"warn"|"error" - Default: unset
- Flag equivalent:
--baseline-error-level - Notes:
baseline-error-levelis a project-level setting and cannot be overridden insub-configsections.- A CLI flag takes precedence over the configuration value.
- The IDE also applies this setting, but displays matched diagnostics as hints when it is unset.
baseline-auto-update
Lets the language server keep the baseline file current as you fix errors. When a file is saved and no longer produces some of the entries recorded for it, those entries are removed from the baseline file.
baseline = "baseline.json"
baseline-auto-update = true
- Type:
boolean - Default:
false - Flag equivalent: none
- Notes:
baseline-auto-updateis a project-level setting and cannot be overridden insub-configsections.- Only entries belonging to the saved file are eligible for removal, so saving one file never discards entries recorded for another. An entry whose file is missing from disk is kept too, because a save says nothing about files it did not look at.
- A saved file that still has errors of its own is left alone, entries and all. Part-way through a fix an entry can look unused only because the code does not type check yet, and removing it would report the error as new once the fix lands. Only diagnostics at or above the severity the baseline was written at count here, so a warning does not hold up an error-only baseline.
- A file edited again after being saved is left alone until the next save, so entries are never judged against unsaved text.
- This setting affects the IDE only. Use
pyrefly check --prune-baselineto do the same thing across a whole project from the command line. Note that--prune-baselinehas no such condition: it removes every unused entry it finds, whether or not new errors remain.
min-severity
The minimum severity level for diagnostics to be displayed by pyrefly check. Diagnostics
below this threshold are hidden from output. Diagnostics at or above the threshold are
displayed and cause a nonzero exit code — for example, --min-severity warn makes
warnings cause a nonzero exit.
When min-severity is not set, pyrefly check displays warnings and errors, and only
errors cause a nonzero exit code. Warnings are also left out of --suppress-errors,
baseline updates and the junit-xml report, which lists only diagnostics that cause a
nonzero exit code.
The lowest threshold, "hint", also shows hint-level diagnostics such as
unused-parameter,
unused-variable,
unused-import,
unreachable, and
inactive-code. These are hidden by default, and
showing them makes them count toward the exit code like any other displayed
diagnostic.
# pyrefly.toml — show warnings and errors
min-severity = "warn"
# pyproject.toml
[tool.pyrefly]
min-severity = "warn"
- Type:
"ignore"|"hint"|"info"|"warn"|"error" - Default: not set (warnings are displayed, and only errors cause a nonzero exit)
- Flag equivalent:
--min-severity - Notes:
min-severityis a project-level setting and cannot be overridden insub-configsections.- This setting only controls CLI display and exit code. To change the severity of individual
error kinds, use the
errorstable instead. - In the IDE, diagnostics below error severity are only shown for files that are currently open in the editor, regardless of this setting.
- Directives such as
reveal_typeare always shown regardless of this threshold.
only
An array of error kinds that restricts which diagnostics Pyrefly processes.
With only set, pyrefly check processes only the listed kinds: it displays
them in the output, allows them to affect the exit code, inserts ignore comments
for them during suppression (--suppress-errors) and records them when
updating baselines (--update-baseline).
# pyrefly.toml
only = ["bad-assignment", "bad-return"]
- Type: Array of error kinds (see error-kinds)
- Default: Not set (no filtering by error kind)
- Flag equivalent:
--only - Notes:
onlyis a project-level setting and cannot be overridden insub-configsections.- The
--onlycommand-line flag completely overrides this configuration value. only = []is rejected as a configuration error to prevent accidentally hiding all diagnostics.
output-format
Default format for pyrefly check error output when --output-format is not
set on the CLI.
- Type:
"min-text" | "full-text" | "json" | "github" | "junit-xml" | "code-climate" | "sarif" | "omit-errors" - Default:
full-text - Flag equivalent:
--output-format - Notes:
output-formatis a project-level setting and cannot be overridden insub-configsections.- A CLI
--output-formatflag takes precedence over the config value and sets the default for every--outputwithout a format prefix. "junit-xml"emits a JUnit XML<testsuites>report suitable for CI dashboards (Jenkins, GitLab MR widgets, CircleCI, Azure DevOps, etc.)."sarif"emits a SARIF 2.1.0 report suitable for static-analysis integrations.
extends
A configuration file to inherit settings from. See Extending a Configuration.
# pyrefly.toml
extends = "pyproject.toml"
- Type: path to a
pyrefly.toml, another TOML configuration file, or apyproject.tomlcontaining[tool.pyrefly], relative to the file that sets it - Default: none
- Flag equivalent: none
- Notes:
extendscannot be set insub-configsections.
required-version
Enforces a requirement on the version of Pyrefly at runtime. Pyrefly reports a
configuration error if its version does not satisfy the requirement. When this
error stops pyrefly check, it exits with code 4. This can keep local CLI runs,
editor integrations, and CI on compatible versions.
# pyrefly.toml
required-version = ">=1.2.0,<2.0.0"
# pyproject.toml
[tool.pyrefly]
required-version = ">=1.2.0,<2.0.0"
- Type: string containing a PEP 440 version specifier
- Default: none
- Flag equivalent: none
- Notes:
required-versionis a project-level setting and cannot be overridden insub-configsections.
preset
A named collection of error severities and behavior settings that serves as the base configuration. Any explicit settings you specify override the preset.
- Type: string (
"off","basic","legacy","default","strict","all") - Default: none (equivalent to
"default") - Flag equivalent:
-p/--preset - Notes:
presetcan also be set insub-configsections and in build system configs. A file uses the first preset it finds, checking its build system config if it has one (see per-target configuration), otherwise the matching sub-configs in the order they appear, then the top-level config. That preset replaces the others rather than combining with them. For example, a sub-config withpreset = "default"under a top-levelpreset = "basic"restores Pyrefly's default behavior for its files.- Settings that any config sets explicitly take precedence over every preset.
If the top-level
[errors]table setsimplicit-any = "error", a sub-config withpreset = "off"still reportsimplicit-anyfor its files unless the sub-config sets it again. --presetreplaces only the top-level preset. Sub-configs and build system configs that set their own preset keep it.
Preset: off
Silences every error kind. Other settings (scalar flags, behavior settings) are left at their defaults. Useful when Pyrefly is running only for IDE features like hover and go-to-definition, without diagnostics.
- Disables every error kind.
Preset: basic
A minimal-checking preset used when automatic configuration selection finds no migratable mypy/pyright configuration (or migration fails). It can also be selected explicitly with preset = "basic", --preset basic, or the IDE's "basic" type-checking mode. It enables parse errors plus a small set of high-confidence, locally-fixable checks. Stricter checks like override validation, annotation completeness, and broader call-shape or assignment validation are disabled.
- Sets
check-unannotated-defs= false,infer-return-types= "never",infer-with-first-use= false, andenabled-ignoresto every tool (equivalent topermissive-ignores= true) - Enables (as errors):
bad-class-definition,bad-instantiation,bad-keyword-argument,bad-raise,bad-unpacking,division-by-zero,invalid-annotation,invalid-literal,invalid-super-call,invalid-syntax,missing-import,not-async,parse-error,unexpected-keyword,unexpected-positional-argument,unknown-name,unused-coroutine - Enables (as warnings):
fallback-search-path-relative-import - Keeps as hints:
inactive-code,unused-import,unused-parameter,unused-variable - Keeps as info:
reveal-type - All other error kinds are silenced.
Preset: legacy
A looser, less-strict preset intended for codebases migrating from mypy. This is the preset pyrefly init writes when it detects an existing mypy configuration. Pyrefly does not aim to mimic mypy precisely, but the preset preserves selected defaults that would otherwise produce new migration errors.
- Sets
check-unannotated-defs= false,infer-return-types= "never",legacy-overload-expansion= true,replace-untyped-imports-with-any= ["*"] - Sets
type-ignore-unknown-tag-behavior= "suppress"so existing mypy-coded ignores retain their legacy blanket-suppression behavior. - Disables:
bad-override-mutable-attribute,bad-override-param-name,unbound-name. When both the parent and child members are plain read-write attributes, widening or incompatible types report plainbad-override, which this preset leaves enabled. Some overrides involving properties, including incompatible property getters, still reportbad-override-mutable-attributeand are suppressed by this preset.