Skip to content

Commit a1a61bc

Browse files
committed
scripts/debug: Fix debugging helper tool checks.
1 parent 49a7554 commit a1a61bc

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def long_description():
9494
"console_scripts": [
9595
"zulip-term = zulipterminal.cli.run:main",
9696
"zulip-term-check-symbols = zulipterminal.scripts.render_symbols:main",
97-
"zulip-term-debug = zulipterminal.scripts.debug_helper:main", # Added debug helper
97+
# Added debug helper with proper path
98+
"zulip-term-debug = zulipterminal.scripts.debug_helper:main",
9899
],
99100
},
100101
extras_require={

zulipterminal/scripts/debug_helper.py

+30-27
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
import re
1414
import subprocess
1515
import json
16-
from pathlib import Path
16+
from typing import Optional, Any
1717

1818

19-
def analyze_debug_log(log_file="debug.log"):
19+
def analyze_debug_log(log_file: str = "debug.log") -> None:
2020
"""
2121
Analyze a debug log file for common issues.
2222
"""
2323
if not os.path.exists(log_file):
24-
print(f"Error: Log file '{log_file}' not found")
24+
print(f"Error: Log file '{log_file}' not found") # noqa: T201
2525
return
2626

27-
print(f"Analyzing {log_file}...")
27+
print(f"Analyzing {log_file}...") # noqa: T201
2828
with open(log_file, 'r') as f:
2929
content = f.read()
3030

@@ -46,14 +46,14 @@ def analyze_debug_log(log_file="debug.log"):
4646
line_end = len(content)
4747

4848
line = content[line_start:line_end].strip()
49-
print(f"Potential issue found: {line}")
49+
print(f"Potential issue found: {line}") # noqa: T201
5050
errors_found = True
5151

5252
if not errors_found:
53-
print("No obvious errors found in the log file.")
53+
print("No obvious errors found in the log file.") # noqa: T201
5454

5555

56-
def test_connectivity(server_url=None):
56+
def test_connectivity(server_url: Optional[str] = None) -> None:
5757
"""
5858
Test connectivity to a Zulip server.
5959
"""
@@ -68,41 +68,41 @@ def test_connectivity(server_url=None):
6868
break
6969

7070
if not server_url:
71-
print("Error: No server URL provided and couldn't find one in ~/.zuliprc")
71+
print("Error: No server URL provided and couldn't find one in ~/.zuliprc") # noqa: T201
7272
return
7373

74-
print(f"Testing connectivity to {server_url}...")
74+
print(f"Testing connectivity to {server_url}...") # noqa: T201
7575
try:
7676
import requests
7777
response = requests.get(f"{server_url}/api/v1/server_settings")
7878
if response.status_code == 200:
79-
print(f"Successfully connected to {server_url}")
79+
print(f"Successfully connected to {server_url}") # noqa: T201
8080
try:
8181
settings = response.json()
82-
print(f"Server version: {settings.get('zulip_version', 'unknown')}")
82+
print(f"Server version: {settings.get('zulip_version', 'unknown')}") # noqa: T201
8383
except json.JSONDecodeError:
84-
print("Received response, but couldn't parse as JSON")
84+
print("Received response, but couldn't parse as JSON") # noqa: T201
8585
else:
86-
print(f"Failed to connect: HTTP status {response.status_code}")
86+
print(f"Failed to connect: HTTP status {response.status_code}") # noqa: T201
8787
except Exception as e:
88-
print(f"Connection error: {e}")
88+
print(f"Connection error: {e}") # noqa: T201
8989

9090

91-
def check_terminal_capabilities():
91+
def check_terminal_capabilities() -> None:
9292
"""
9393
Check for terminal capabilities that might affect Zulip Terminal.
9494
"""
95-
print("Checking terminal capabilities...")
95+
print("Checking terminal capabilities...") # noqa: T201
9696

9797
# Check for color support
9898
colors = os.environ.get('TERM', 'unknown')
99-
print(f"TERM environment: {colors}")
99+
print(f"TERM environment: {colors}") # noqa: T201
100100

101101
if 'COLORTERM' in os.environ:
102-
print(f"COLORTERM: {os.environ['COLORTERM']}")
102+
print(f"COLORTERM: {os.environ['COLORTERM']}") # noqa: T201
103103

104104
# Check for Unicode support
105-
print("\nTesting Unicode rendering capabilities:")
105+
print("\nTesting Unicode rendering capabilities:") # noqa: T201
106106
test_chars = [
107107
("Basic symbols", "▶ ◀ ✓ ✗"),
108108
("Emoji (simple)", "😀 🙂 👍"),
@@ -111,19 +111,22 @@ def check_terminal_capabilities():
111111
]
112112

113113
for name, chars in test_chars:
114-
print(f" {name}: {chars}")
114+
print(f" {name}: {chars}") # noqa: T201
115115

116116
# Check for urwid compatibility
117117
try:
118-
import urwid
119-
print("\nUrwid detected. Running basic urwid test...")
118+
import urwid # noqa: F401
119+
print("\nUrwid detected. Running basic urwid test...") # noqa: T201
120120
# This doesn't actually run a visual test - just checks if urwid can be imported
121-
print("Urwid import successful")
121+
print("Urwid import successful") # noqa: T201
122122
except ImportError:
123-
print("Urwid not found. This may indicate installation issues.")
123+
print("Urwid not found. This may indicate installation issues.") # noqa: T201
124124

125125

126-
def main():
126+
def main() -> None:
127+
"""
128+
Main entry point for the debugging helper.
129+
"""
127130
parser = argparse.ArgumentParser(description="Zulip Terminal Debugging Helper")
128131
subparsers = parser.add_subparsers(dest="command", help="Command to run")
129132

@@ -136,7 +139,7 @@ def main():
136139
conn_parser.add_argument("--server", help="Server URL (e.g., https://chat.zulip.org)")
137140

138141
# Terminal test
139-
term_parser = subparsers.add_parser("terminal", help="Check terminal capabilities")
142+
subparsers.add_parser("terminal", help="Check terminal capabilities")
140143

141144
# Run zulip-term with debug
142145
run_parser = subparsers.add_parser("run", help="Run zulip-term with debugging")
@@ -154,7 +157,7 @@ def main():
154157
cmd = ["zulip-term", "-d"]
155158
if args.profile:
156159
cmd.append("--profile")
157-
print(f"Running: {' '.join(cmd)}")
160+
print(f"Running: {' '.join(cmd)}") # noqa: T201
158161
subprocess.run(cmd)
159162
else:
160163
parser.print_help()

0 commit comments

Comments
 (0)