Skip to content

Improve color and terminal width overrides #7674

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 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mypy/dmypy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,9 @@ def request(status_file: str, command: str, *, timeout: Optional[int] = None,
args['command'] = command
# Tell the server whether this request was initiated from a human-facing terminal,
# so that it can format the type checking output accordingly.
args['is_tty'] = sys.stdout.isatty()
args['terminal_width'] = get_terminal_width()
args['is_tty'] = sys.stdout.isatty() or int(os.getenv('MYPY_FORCE_COLOR', '0')) > 0
args['terminal_width'] = (int(os.getenv('MYPY_FORCE_TERMINAL_WIDTH', '0')) or
get_terminal_width())
bdata = json.dumps(args).encode('utf8')
_, name = get_status(status_file)
try:
Expand Down
2 changes: 0 additions & 2 deletions mypy/dmypy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,6 @@ def run_command(self, command: str, data: Dict[str, object]) -> Dict[str, object
# Only the above commands use some error formatting.
del data['is_tty']
del data['terminal_width']
elif int(os.getenv('MYPY_FORCE_COLOR', '0')):
data['is_tty'] = True
return method(self, **data)

# Command functions (run in the server via RPC).
Expand Down
3 changes: 2 additions & 1 deletion mypy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,8 @@ def style(self, text: str, color: Literal['red', 'green', 'blue', 'yellow', 'non
def fit_in_terminal(self, messages: List[str],
fixed_terminal_width: Optional[int] = None) -> List[str]:
"""Improve readability by wrapping error messages and trimming source code."""
width = fixed_terminal_width or get_terminal_width()
width = (fixed_terminal_width or int(os.getenv('MYPY_FORCE_TERMINAL_WIDTH', '0')) or
get_terminal_width())
new_messages = messages.copy()
for i, error in enumerate(messages):
if ': error:' in error:
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy