Skip to content

Commit f9af375

Browse files
author
salehMomtaz
committed
fix(lsp): point pyright at the project venv; drop stale operators.downloader fallback
opencode's pyright langserver never resolved the project venv (anomalyco/opencode#6131 — it sets a flat initialization pythonPath, which pyright ignores), so every third-party import (pyrogram/kurigram, instagrapi, dotenv, playwright) surfaced as a false 'could not be resolved' error. pyrightconfig.json now declares venvPath/venv + pythonVersion explicitly and demotes the pyrogram-stub false-positive families (Optional-member/argument/attribute access etc.) to warnings; import resolution and undefined names stay as errors. Repo-wide pyright: 0 errors. Also removes the dead 'from operators.downloader import ...' fallback in modules/youtube/handlers.py (module has not existed since the utils/downloader/ split; the primary import right above it is used).
1 parent 4cf6225 commit f9af375

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

‎modules/youtube/handlers.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,11 @@ def extract_subs():
144144
if getattr(config, 'YTDLP_USER_AGENT', ''):
145145
ydl_opts['user_agent'] = config.YTDLP_USER_AGENT
146146
try:
147-
pass
148147
# use url_normalize's patch if available
149148
from utils.downloader.url_normalize import _apply_pot_options as _pot
150149
ydl_opts = _pot(ydl_opts, url)
151150
except Exception:
152-
try:
153-
from operators.downloader import _apply_pot_options as _old
154-
ydl_opts = _old(ydl_opts, url)
155-
except: pass
151+
pass
156152
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
157153
return ydl.extract_info(url, download=True)
158154
try:

‎pyrightconfig.json‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
3+
"pythonVersion": "3.12",
4+
"venvPath": ".",
5+
"venv": "venv",
6+
"reportPrivateImportUsage": "none",
7+
"reportOptionalMemberAccess": "warning",
8+
"reportOptionalSubscript": "warning",
9+
"reportOptionalIterable": "warning",
10+
"reportOptionalOperand": "warning",
11+
"reportOptionalCall": "warning",
12+
"reportArgumentType": "warning",
13+
"reportAttributeAccessIssue": "warning",
14+
"reportCallIssue": "warning",
15+
"reportAssignmentType": "warning",
16+
"reportIndexIssue": "warning",
17+
"reportReturnType": "warning",
18+
"reportGeneralTypeIssues": "warning",
19+
"reportTypedDictNotRequiredAccess": "warning",
20+
"reportOperatorIssue": "warning",
21+
"reportPossiblyUnboundVariable": "warning"
22+
}

0 commit comments

Comments
 (0)