Skip to content

Re-add fallback for zero terminal width #9651

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 1 commit into from
Oct 28, 2020
Merged

Re-add fallback for zero terminal width #9651

merged 1 commit into from
Oct 28, 2020

Conversation

The-Compiler
Copy link
Contributor

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

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
@The-Compiler
Copy link
Contributor Author

FWIW I also opened a Python bug about this now, since I feel like shutil.get_terminal_size() should handle this correctly (rather than mypy needing to work around it).

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! This is clearly an area with some tricky edge cases, so adding a test makes sense.

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.

Using --pretty prints each word of error on new line
2 participants