Skip to content

Commit d13e24e

Browse files
committed
fix some lint
1 parent 45edc03 commit d13e24e

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed

deepcode.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,35 @@
1414

1515
def check_dependencies():
1616
"""Check if necessary dependencies are installed"""
17+
import importlib.util
18+
1719
print("🔍 Checking dependencies...")
1820

1921
missing_deps = []
2022
missing_system_deps = []
2123

22-
try:
23-
import streamlit
24-
24+
# Check Streamlit availability
25+
if importlib.util.find_spec("streamlit") is not None:
2526
print("✅ Streamlit is installed")
26-
except ImportError:
27+
else:
2728
missing_deps.append("streamlit>=1.28.0")
2829

29-
try:
30-
import yaml
31-
30+
# Check PyYAML availability
31+
if importlib.util.find_spec("yaml") is not None:
3232
print("✅ PyYAML is installed")
33-
except ImportError:
33+
else:
3434
missing_deps.append("pyyaml")
3535

36-
try:
37-
import asyncio
38-
36+
# Check asyncio availability
37+
if importlib.util.find_spec("asyncio") is not None:
3938
print("✅ Asyncio is available")
40-
except ImportError:
39+
else:
4140
missing_deps.append("asyncio")
4241

4342
# Check PDF conversion dependencies
44-
try:
45-
import reportlab
46-
43+
if importlib.util.find_spec("reportlab") is not None:
4744
print("✅ ReportLab is installed (for text-to-PDF conversion)")
48-
except ImportError:
45+
else:
4946
missing_deps.append("reportlab")
5047
print("⚠️ ReportLab not found (text files won't convert to PDF)")
5148

tools/git_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async def check_git_installed() -> bool:
126126
)
127127
await proc.wait()
128128
return proc.returncode == 0
129-
except:
129+
except Exception:
130130
return False
131131

132132

tools/pdf_converter.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,9 @@ def check_dependencies(self) -> dict:
556556
pass
557557

558558
# Check ReportLab
559-
try:
560-
import reportlab
561-
559+
import importlib.util
560+
if importlib.util.find_spec("reportlab") is not None:
562561
results["reportlab"] = True
563-
except ImportError:
564-
pass
565562

566563
return results
567564

tools/pdf_downloader.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ async def check_url_accessible(url: str) -> Dict[str, Any]:
753753
"content_type": response.headers.get("Content-Type", ""),
754754
"content_length": response.headers.get("Content-Length", 0),
755755
}
756-
except:
756+
except Exception:
757757
return {
758758
"accessible": False,
759759
"status": 0,
@@ -775,7 +775,6 @@ async def download_file(url: str, destination: str) -> Dict[str, Any]:
775775
response.raise_for_status()
776776

777777
# 获取文件信息
778-
total_size = int(response.headers.get("Content-Length", 0))
779778
content_type = response.headers.get(
780779
"Content-Type", "application/octet-stream"
781780
)
@@ -1264,7 +1263,7 @@ async def convert_document_to_markdown(
12641263
try:
12651264
parsed = urlparse(file_path)
12661265
is_url_input = parsed.scheme in ("http", "https")
1267-
except:
1266+
except Exception:
12681267
is_url_input = False
12691268

12701269
# 检查文件是否存在(如果不是URL)

0 commit comments

Comments
 (0)