Report an empty TOML command value as a handled error - #4041
Merged
gaborbernat merged 1 commit intoAug 25, 2026
Conversation
dylanpulver
force-pushed
the
fix/toml-empty-scalar-command
branch
from
August 24, 2026 19:48
0ca0ccc to
ac4e877
Compare
gaborbernat
force-pushed
the
fix/toml-empty-scalar-command
branch
from
August 25, 2026 03:59
ac4e877 to
9595a43
Compare
gaborbernat
approved these changes
Aug 25, 2026
gaborbernat
enabled auto-merge (squash)
August 25, 2026 04:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
install_command = []in TOML raisesAttributeError: 'NoneType' object has no attribute 'args'with a traceback and exit code 2.list_dependencies_command = []does the same. The ini spellinginstall_command=reportsunable to determine pip install command: attempting to parse '' into a command failedand exits 1.The cause
Convert.to_commandis declaredCommand | None, and the two loaders disagree on whatNonemeans.StrConvert.to_command("")raisesValueError;TomlLoader.to_command([])returnsNone, which is what lets #3388 drop empty entries insidecommands. For a scalarof_type=CommandthatNoneis cast straight through to the caller, which then dereferences it.The fix
to_commandnow returns aCommandor raises, in every loader. The TOML rule that an empty entry inside a list of commands is dropped moves intoTomlLoader.to_list, which is whereStrConvert.to_listalready drops empty tokens.convert.pyloses itsCommand-shaped branch in the shared list path, so the format-specific rule no longer leaks into the format-agnostic layer.Making the abstract return type
Commandalso surfaced thatStrConvert.to_commandnever returnedNonein the first place -tyrejected the override until the annotation was corrected.Both formats now stop before the dereference:
Drive-by:
TomlLoader.to_setwas a byte-for-byte copy ofto_listand now delegates to it.Verification
test_toml_loader_command_empty_nokcovers the scalar rejection andtest_toml_loader_command_list_drops_emptypins the #3388 behaviour; removing either half of the change fails the matching test.test_pip_toml_empty_command_erroris parametrised overinstall_commandandlist_dependencies_command, the two scalarCommandsettings.Full suite passes, as do
tox -e type(ty, mypy, pyrefly) andtox -e fix.tox -e fix)docs/changelogfolder