Skip to content

Commit

Permalink
pyright: turn on reportIndexIssue + reportIndexIssue
Browse files Browse the repository at this point in the history
Work towards reportCallIssue
  • Loading branch information
Avasam committed Mar 18, 2024
1 parent e0fda45 commit 22a919f
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ max_line_length = 88 # Same as Black
[*.md]
trim_trailing_whitespace = false

[*.{yaml,yml}]
[*.{yaml,yml,json}]
indent_size = 2
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def ColorizeInteractiveCode(self, cdoc, styleStart, stylePyStart):
if ch not in "\r\n":
self.ColorSeg(startSeg, i - 1, state)
startSeg = i
if ch in (sys.ps1[0], sys.ps2[0]):
if ch in (str(sys.ps1)[0], str(sys.ps2)[0]):
state = STYLE_INTERACTIVE_PROMPT
elif cdoc[i : i + len(tracebackHeader)] == tracebackHeader:
state = STYLE_INTERACTIVE_ERROR
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/scintilla/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def RegisterStyle(self, style, stylenum=None):
self.nextstylenum = self.nextstylenum + 1
FormatterBase.RegisterStyle(self, style, stylenum)

def ColorizeString(self, str, charStart, styleStart):
def ColorizeString(self, str, styleStart):
raise RuntimeError("You must override this method")

def Colorize(self, start=0, end=-1):
Expand Down
4 changes: 2 additions & 2 deletions Pythonwin/win32uimodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1603,8 +1603,8 @@ static PyObject *ui_set_dialog_bk_color(PyObject *self, PyObject *args)
int clrCtlBk = RGB(192, 192, 192);
int clrCtlText = RGB(0, 0, 0);

// @pyparm int|clrCtlBk|win32ui.RGB(192, 192, 192)|The color for the controls background.
// @pyparm int|clrCtlText|win32ui.RGB(0, 0, 0)|The color for the controls text.
// @pyparm int|clrCtlBk|win32api.RGB(192, 192, 192)|The color for the controls background.
// @pyparm int|clrCtlText|win32api.RGB(0, 0, 0)|The color for the controls text.
if (!PyArg_ParseTuple(args, "|ii:SetDialogBkColor", &clrCtlBk, &clrCtlText))
return NULL;
CProtectedWinApp *pApp = GetProtectedApp();
Expand Down
3 changes: 2 additions & 1 deletion com/win32comext/axdebug/codecontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def GetSyntaxColorAttributes(self):
self.lastPos = 0
self.attrs = []
try:
tokenize.tokenize(self.GetNextLine, self._ProcessToken)
for tokens in tokenize.tokenize(self.GetNextLine):
self._ProcessToken(*tokens)
except tokenize.TokenError:
pass # Ignore - will cause all subsequent text to be commented.
numAtEnd = len(self.GetText()) - self.lastPos
Expand Down
4 changes: 2 additions & 2 deletions com/win32comext/axscript/client/pydumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ def Register():
RegisterServer(
clsid=clsid,
pythonInstString="win32com.axscript.client.pyscript.PyDumper",
className="Python Debugging/Dumping ActiveX Scripting Engine",
desc="Python Debugging/Dumping ActiveX Scripting Engine",
progID=languageName,
verProgID=verProgId,
catids=categories,
policy=policy,
catids=categories,
dispatcher=dispatcher,
)

Expand Down
10 changes: 4 additions & 6 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"typeCheckingMode": "basic",
// Target the oldest supported version in editors
// Target the oldest supported version in editors and default CLI
"pythonVersion": "3.7",
// Keep it simple for now by allowing both mypy and pyright to use `type: ignore`
"enableTypeIgnoreComments": true,
// Exclude from scanning when running pyright
"exclude": [
"build/",
// TODO: adodbapi should be updated and fixed separatly
// TODO: adodbapi should be updated and fixed separately
"adodbapi/",
// Vendored
"Pythonwin/Scintilla/",
// Vendored IDLE extensions predating Python 2.3. They now live in idlelib in https://github.com/python/cpython/tree/main/Lib/idlelib
// Forked IDLE extensions predating Python 2.3. They now live in idlelib in https://github.com/python/cpython/tree/main/Lib/idlelib
"Pythonwin/pywin/idle/",
// Ignoring non-public apis for now
"**/Test/",
Expand All @@ -33,15 +33,13 @@
"reportAttributeAccessIssue": "none",
// FIXE: These all need to be fixed first and turned back to error
// some of the fixes need to be done in types-pywin32 from typeshed
"reportAssignmentType": "warning",
"reportCallIssue": "warning",
"reportIndexIssue": "warning",
"reportOperatorIssue": "warning",
"reportOptionalCall": "warning",
"reportOptionalIterable": "warning",
"reportOptionalMemberAccess": "warning",
"reportOptionalSubscript": "warning",
// TODO: Leave Unbound/Undefined to its own PR(s)
// TODO: Leave Unbound/Undefined to their own PR(s)
"reportUnboundVariable": "warning",
"reportUndefinedVariable": "warning",
// Too many dynamically generated modules. This will require type stubs to properly fix.
Expand Down
2 changes: 1 addition & 1 deletion win32/scripts/setup_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _docopy(src, dest):
return 1
except:
print(f"Error copying '{src}' -> '{dest}'")
print(str(sys.exc_info[1]))
print(str(sys.exc_info()[1]))
usage_and_die(3)


Expand Down

0 comments on commit 22a919f

Please sign in to comment.