Skip to content

Add an option to disable the PYTHONPATH warning - #5662

Open
Primeteumm wants to merge 1 commit into
pyrefly-org:mainfrom
Primeteumm:disable-pythonpath-warning
Open

Primeteumm wants to merge 1 commit into
pyrefly-org:mainfrom
Primeteumm:disable-pythonpath-warning

Conversation

@Primeteumm

Copy link
Copy Markdown

Summary

Fixes #5315

  • I am a human, and I fully understand the code I am submitting.

When PYTHONPATH is set, Pyrefly previously logged a long warning every time it queried a Python interpreter, which adds a lot of noise in build and test environments that rely on PYTHONPATH.

This adds a disable-pythonpath-warning setting (defaulting to false) in pyrefly.toml / pyproject.toml and a matching --disable-pythonpath-warning[=true|false] CLI flag that overrides the config in either direction. To respect the config, I moved the warning check out of the interpreter query and into ConfigFile, so it now applies to both pyrefly check and the LSP and fires at most once per run. I also updated the warning message to mention how to turn it off, along with the docs and JSON schema.

I claimed #5315 in the issue comments earlier, though the claim bot hasn't assigned me yet.

Test Plan

  • Added disable_pythonpath_warning_flag unit test to verify the CLI flag overrides the config value both ways, and ran the existing pyrefly_config, config_finder, and workspace tests.
  • Added 3 test cases in test/interpreter.md covering the default warning, CLI flag suppression, and config suppression. Since scrut isn't available on my Windows machine, I ran the commands manually against the built binary (CI will run them).
  • Ran formatting and lint checks. Note that local testing was on Windows only, and the LSP path was checked by reading through the code rather than with an automated test.

AI Disclosure

The code and tests were written with Claude Code; I reviewed and verified the changes myself.

Build and test systems often need PYTHONPATH set, so the warning Pyrefly
prints when it queries an interpreter with PYTHONPATH set is noise for
those users, and it gets long when PYTHONPATH is long. Fixes pyrefly-org#5315.

Add a `disable-pythonpath-warning` config option and an equivalent
`--disable-pythonpath-warning` flag; the flag overrides the config value.

The warning now lives on `ConfigFile`, where the option is available,
instead of in the interpreter query itself. It is emitted before the CLI
and the language server query an interpreter. Because PYTHONPATH is fixed
for the life of the process, it is printed at most once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Primeteumm
Primeteumm force-pushed the disable-pythonpath-warning branch from d80226a to 00194da Compare November 18, 2026 18:11
@meta-codesync

meta-codesync Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D132949590. (Because this pull request was imported automatically, there will not be any future comments.)

@github-actions

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

This branch has not been deployed

No deployments
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.

configuration option to disable the PYTHONPATH warning

2 participants