Skip to content

mypy's --pretty option printing one word per line when used with pre-commit #8816

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

Closed
deveshks opened this issue May 13, 2020 · 4 comments
Closed

Comments

@deveshks
Copy link

On running mypy as a pre-commit hook along with --pretty option, mypy prints one word per line.

For example, after having the following pre-commit configuration with pip which includes the --pretty option

https://github.com/pypa/pip/blob/d911a9fcb8d29ed560ba0ccb16f83f914a37a2a7/.pre-commit-config.yaml#L31-L41

If I introduce a mypy error, it looks like:

$ pre-commit run mypy --files src/pip/_internal/cli/main_parser.py
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

src/pip/_internal/cli/main_parser.py:47: error:
"ConfigOptionParser"
has
no
attribute
"main"
        parser.main = True
        ^
Found 1 error in 1 file (checked 1 source file)

mypy, for Python 2.......................................................Failed
- hook id: mypy
- exit code: 1

src/pip/_internal/cli/main_parser.py:47: error:
"ConfigOptionParser"
has
no
attribute
"main"
        parser.main = True
        ^
Found 1 error in 1 file (checked 1 source file)
@pradyunsg
Copy link
Member

This is eerily similar to #8144, which was filed as a result of a discussion between @asottile and myself, about a pre-commit + mypy's --pretty not working well together.

@asottile
Copy link
Contributor

I believe that only got fixed in v0.770 and it looks like pip is still on v0.760

@deveshks
Copy link
Author

deveshks commented May 13, 2020

I believe that only got fixed in v0.770 and it looks like pip is still on v0.760

Yep, I updated https://github.com/pypa/pip/blob/d911a9fcb8d29ed560ba0ccb16f83f914a37a2a7/.pre-commit-config.yaml#L32 to v0.770 , along with using --pretty and see the following now

$ pre-commit run mypy --files src/pip/_internal/cli/main_parser.py
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

src/pip/_internal/cli/main_parser.py:47: error: "ConfigOptionParser" has no
attribute "main"
        parser.main = True
        ^
Found 1 error in 1 file (checked 1 source file)

mypy, for Python 2.......................................................Failed
- hook id: mypy
- exit code: 1

src/pip/_internal/cli/main_parser.py:47: error: "ConfigOptionParser" has no
attribute "main"
        parser.main = True
        ^
Found 1 error in 1 file (checked 1 source file)

@emmatyping
Copy link
Member

Thanks @pradyunsg and @asottile!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants