Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pre-commit hook when called with multiple files #41

Merged
merged 9 commits into from
May 17, 2022
Prev Previous commit
Next Next commit
Print name of the file being validated
  • Loading branch information
abravalheri committed May 16, 2022
commit f0f19093c157e76259f6a4b535bd4a8a4fcf71ba
8 changes: 7 additions & 1 deletion src/validate_pyproject/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def run(args: Sequence[str] = ()):
if params.dump_json:
print(json.dumps(toml_equivalent, indent=2))
else:
print("Valid file")
print(f"Valid {_format_file(params.input_file)}")
return 0


Expand Down Expand Up @@ -226,3 +226,9 @@ def _format_plugin_help(plugin: PluginWrapper) -> str:
help_text = plugin.help_text
help_text = f": {_flatten_str(help_text)}" if help_text else ""
return f'* "{plugin.tool}"{help_text}'


def _format_file(file: io.TextIOBase) -> str:
if hasattr(file, "name") and file.name: # type: ignore[attr-defined]
return f"file: {file.name}" # type: ignore[attr-defined]
return "file"