Allow for reading TOML files from stdin.#239
Merged
gaborbernat merged 1 commit intotox-dev:mainfrom Jul 30, 2024
fniessink:238-allow-for-reading-from-stdin
Merged
Allow for reading TOML files from stdin.#239gaborbernat merged 1 commit intotox-dev:mainfrom fniessink:238-allow-for-reading-from-stdin
gaborbernat merged 1 commit intotox-dev:mainfrom
fniessink:238-allow-for-reading-from-stdin
Conversation
gaborbernat
requested changes
Jul 24, 2024
gaborbernat
requested changes
Jul 24, 2024
gaborbernat
requested changes
Jul 30, 2024
tests/test_cli.py
Outdated
|
|
||
|
|
||
| def test_cli_pyproject_toml_stdin(monkeypatch: pytest.MonkeyPatch) -> None: | ||
| monkeypatch.setattr("sys.stdin", io.StringIO("")) |
Member
There was a problem hiding this comment.
Use pytest-mock instead like the rest of the codebase.
fniessink
commented
Jul 30, 2024
Contributor
Author
fniessink
left a comment
There was a problem hiding this comment.
How would you like me to deal with the typing error in __main__.py?
In _handle_one, after the if config.stdout block, config.pyproject_toml is never None, but the type checker can't detect that:
def _handle_one(config: Config) -> bool:
formatted = format_toml(config.toml, config.settings)
before = config.toml
changed = before != formatted
if config.stdout: # stdout just prints new format to stdout
print(formatted, end="") # noqa: T201
return changed
if before != formatted and not config.check:
config.pyproject_toml.write_text(formatted, encoding="utf-8")I see a few options:
- casting to
Path - changing the
if config.stdouttoif config.pyproject_toml is None or config.stdout
There are probably other options as well.
Member
|
either is fine |
When the input filename is '-', read the toml from stdin and output to stdout. Closes #238.
auto-merge was automatically disabled
July 30, 2024 16:35
Head branch was pushed to by a user without write access
Contributor
Author
|
Now with a signed commit. |
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.



When the input filename is '-', read the toml from stdin and output to stdout.
Closes #238.