13
13
import re
14
14
import subprocess
15
15
import json
16
- from pathlib import Path
16
+ from typing import Optional , Any
17
17
18
18
19
- def analyze_debug_log (log_file = "debug.log" ):
19
+ def analyze_debug_log (log_file : str = "debug.log" ) -> None :
20
20
"""
21
21
Analyze a debug log file for common issues.
22
22
"""
23
23
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
25
25
return
26
26
27
- print (f"Analyzing { log_file } ..." )
27
+ print (f"Analyzing { log_file } ..." ) # noqa: T201
28
28
with open (log_file , 'r' ) as f :
29
29
content = f .read ()
30
30
@@ -46,14 +46,14 @@ def analyze_debug_log(log_file="debug.log"):
46
46
line_end = len (content )
47
47
48
48
line = content [line_start :line_end ].strip ()
49
- print (f"Potential issue found: { line } " )
49
+ print (f"Potential issue found: { line } " ) # noqa: T201
50
50
errors_found = True
51
51
52
52
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
54
54
55
55
56
- def test_connectivity (server_url = None ):
56
+ def test_connectivity (server_url : Optional [ str ] = None ) -> None :
57
57
"""
58
58
Test connectivity to a Zulip server.
59
59
"""
@@ -68,41 +68,41 @@ def test_connectivity(server_url=None):
68
68
break
69
69
70
70
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
72
72
return
73
73
74
- print (f"Testing connectivity to { server_url } ..." )
74
+ print (f"Testing connectivity to { server_url } ..." ) # noqa: T201
75
75
try :
76
76
import requests
77
77
response = requests .get (f"{ server_url } /api/v1/server_settings" )
78
78
if response .status_code == 200 :
79
- print (f"Successfully connected to { server_url } " )
79
+ print (f"Successfully connected to { server_url } " ) # noqa: T201
80
80
try :
81
81
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
83
83
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
85
85
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
87
87
except Exception as e :
88
- print (f"Connection error: { e } " )
88
+ print (f"Connection error: { e } " ) # noqa: T201
89
89
90
90
91
- def check_terminal_capabilities ():
91
+ def check_terminal_capabilities () -> None :
92
92
"""
93
93
Check for terminal capabilities that might affect Zulip Terminal.
94
94
"""
95
- print ("Checking terminal capabilities..." )
95
+ print ("Checking terminal capabilities..." ) # noqa: T201
96
96
97
97
# Check for color support
98
98
colors = os .environ .get ('TERM' , 'unknown' )
99
- print (f"TERM environment: { colors } " )
99
+ print (f"TERM environment: { colors } " ) # noqa: T201
100
100
101
101
if 'COLORTERM' in os .environ :
102
- print (f"COLORTERM: { os .environ ['COLORTERM' ]} " )
102
+ print (f"COLORTERM: { os .environ ['COLORTERM' ]} " ) # noqa: T201
103
103
104
104
# Check for Unicode support
105
- print ("\n Testing Unicode rendering capabilities:" )
105
+ print ("\n Testing Unicode rendering capabilities:" ) # noqa: T201
106
106
test_chars = [
107
107
("Basic symbols" , "▶ ◀ ✓ ✗" ),
108
108
("Emoji (simple)" , "😀 🙂 👍" ),
@@ -111,19 +111,22 @@ def check_terminal_capabilities():
111
111
]
112
112
113
113
for name , chars in test_chars :
114
- print (f" { name } : { chars } " )
114
+ print (f" { name } : { chars } " ) # noqa: T201
115
115
116
116
# Check for urwid compatibility
117
117
try :
118
- import urwid
119
- print ("\n Urwid detected. Running basic urwid test..." )
118
+ import urwid # noqa: F401
119
+ print ("\n Urwid detected. Running basic urwid test..." ) # noqa: T201
120
120
# 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
122
122
except ImportError :
123
- print ("Urwid not found. This may indicate installation issues." )
123
+ print ("Urwid not found. This may indicate installation issues." ) # noqa: T201
124
124
125
125
126
- def main ():
126
+ def main () -> None :
127
+ """
128
+ Main entry point for the debugging helper.
129
+ """
127
130
parser = argparse .ArgumentParser (description = "Zulip Terminal Debugging Helper" )
128
131
subparsers = parser .add_subparsers (dest = "command" , help = "Command to run" )
129
132
@@ -136,7 +139,7 @@ def main():
136
139
conn_parser .add_argument ("--server" , help = "Server URL (e.g., https://chat.zulip.org)" )
137
140
138
141
# Terminal test
139
- term_parser = subparsers .add_parser ("terminal" , help = "Check terminal capabilities" )
142
+ subparsers .add_parser ("terminal" , help = "Check terminal capabilities" )
140
143
141
144
# Run zulip-term with debug
142
145
run_parser = subparsers .add_parser ("run" , help = "Run zulip-term with debugging" )
@@ -154,7 +157,7 @@ def main():
154
157
cmd = ["zulip-term" , "-d" ]
155
158
if args .profile :
156
159
cmd .append ("--profile" )
157
- print (f"Running: { ' ' .join (cmd )} " )
160
+ print (f"Running: { ' ' .join (cmd )} " ) # noqa: T201
158
161
subprocess .run (cmd )
159
162
else :
160
163
parser .print_help ()
0 commit comments