-
Notifications
You must be signed in to change notification settings - Fork 16
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
Use pydoclint as pre-commit hook #20
Comments
Interesting... This is because pydoclint tries to print an emoji (🎉) in the stdout: Line 221 in c888c72
So somehow, either pre-commit or Windows decided to not render emojis. Btw, I've never tried to use pydoclint as a pre-commit hook yet (there's an ongoing PR to support it: #18). Let me try it out on my computer (macOS). I'll get back to you. |
I just confirmed that on macOS, "🎉" can be rendered correctly in the terminal with pre-commit. I guess I'll need to create a non-emoji stdout for Windows then. |
That'd be great. |
Not sure what exactly but black does something that makes it work Using the pre-commit config from @liebsc21 I could reproduce the error with But if I do the same with black it manages to print things w/o crashing - repo: local
hooks:
- id: pydoclint
name: pydoclint
entry: pydoclint --config=pyproject.toml
language: system
files: ^(src|tests|rest_api)/.*\.py$
always_run: true
- id: black-local
name: black-local
entry: black
language: system
files: ^(src|tests|rest_api)/.*\.py$
always_run: true
|
Ok found it, looks like windows, click or pre-cmmit is handling encoding in stdout differently than in stderr. - click.echo(click.style("🎉 No violations 🎉", fg="green", bold=True))
+ click.echo(click.style("🎉 No violations 🎉", fg="green", bold=True), err=True) |
Hi @s-weigand , thanks for finding out how Black bypasses this issue! That explains why when I ran Black and got " I think Black's hacky way here can lead to confusions -- both for the users and for the developers. That's why I made this suggestion in the PR here. |
Thanks again for the quick fix. |
Hi @liebsc21 , I just released 0.0.8. |
I like to use pydoclint as pre-commit hook.
It works perfectly well when running it from the CL
pydoclint --config=pyproject.toml src tests rest_api
.But running the hook defined in
pre-commit-config.yaml
:with
pre-commit run --all-files --hook-stage manual pydoclint
results inIt seems that it lints all files it should, but for some a UnicodeEncodeError is raised. Any ideas?
The text was updated successfully, but these errors were encountered: