Skip to content

Fix mypy pretty output within a pty #8145

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

Merged
merged 2 commits into from
Dec 14, 2019
Merged

Fix mypy pretty output within a pty #8145

merged 2 commits into from
Dec 14, 2019

Conversation

asottile
Copy link
Contributor

Resolves #8144

here's the same script that was used in the reproduction for #8144:

$ python3 ../wut/t.py mypy --pretty ../wut/t.py 
../wut/t.py:6: error: Incompatible types in assignment (expression has type
"str", variable has type "int")
    x: int = 'nope'
             ^
Found 1 error in 1 file (checked 1 source file)

@msullivan
Copy link
Collaborator

This looks good and is a good catch. The test strikes me as super marginal though, so let's just skip adding it.

@asottile
Copy link
Contributor Author

deleted the test, seems weird to not have a regression test for this fix but that's not my call!

@msullivan
Copy link
Collaborator

I think an integration test to catch a regression here could be useful but it doesn't seem super useful to me to have a unit test that just recapitulates the code in a straightforward way?

@msullivan msullivan merged commit a918ce8 into python:master Dec 14, 2019
@asottile asottile deleted the pty_terminal_size branch December 14, 2019 18:55
@asottile
Copy link
Contributor Author

looks like I should have added a test as this has regressed: https://github.com/pre-commit/mirrors-mypy/issues/29

JukkaL pushed a commit that referenced this pull request Oct 28, 2020
Contrary to what I assumed in #9143, shutil.get_terminal_size() doesn't
actually handle a 0 width from os.get_terminal_size() - it only handles
a 0 COLUMNS environment variable.

Thus, this caused #8144 to regress.

This change re-adds and uses DEFAULT_COLUMNS and also adds the test
which was deemed unnecessary in #8145 - this regression proves that I'd
have been a good idea to add it in the first place.
(Test written by Anthony Sottile)

Fixes https://github.com/pre-commit/mirrors-mypy/issues/29
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

Successfully merging this pull request may close these issues.

mypy produces mangled output when run with a pty
3 participants