diff --git a/Pythonwin/pywin/Demos/cmdserver.py b/Pythonwin/pywin/Demos/cmdserver.py index cb751f0847..7e3405a1ee 100644 --- a/Pythonwin/pywin/Demos/cmdserver.py +++ b/Pythonwin/pywin/Demos/cmdserver.py @@ -11,22 +11,22 @@ class ThreadWriter: - "Assign an instance to sys.stdout for per-thread printing objects - Courtesy Guido!" + """Assign an instance to sys.stdout for per-thread printing objects - Courtesy Guido!""" def __init__(self): - "Constructor -- initialize the table of writers" + """Constructor -- initialize the table of writers""" self.writers = {} self.origStdOut = None def register(self, writer): - "Register the writer for the current thread" + """Register the writer for the current thread""" self.writers[_thread.get_ident()] = writer if self.origStdOut is None: self.origStdOut = sys.stdout sys.stdout = self def unregister(self): - "Remove the writer for the current thread, if any" + """Remove the writer for the current thread, if any""" try: del self.writers[_thread.get_ident()] except KeyError: @@ -36,11 +36,11 @@ def unregister(self): self.origStdOut = None def getwriter(self): - "Return the current thread's writer, default sys.stdout" + """Return the current thread's writer, default sys.stdout""" self.writers.get(_thread.get_ident(), self.origStdOut) def write(self, str): - "Write to the current thread's writer, default sys.stdout" + """Write to the current thread's writer, default sys.stdout""" self.getwriter().write(str) diff --git a/Pythonwin/pywin/Demos/ocx/flash.py b/Pythonwin/pywin/Demos/ocx/flash.py index 5a5f8ccc89..f69ae687d6 100644 --- a/Pythonwin/pywin/Demos/ocx/flash.py +++ b/Pythonwin/pywin/Demos/ocx/flash.py @@ -60,7 +60,7 @@ def __init__(self, url=None): self.url = regutil.GetRegisteredHelpFile("Main Python Documentation") else: self.url = url - pass # Don't call base class doc/view version... + # Don't call base class doc/view version... def Create(self, title, rect=None, parent=None): style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_OVERLAPPEDWINDOW diff --git a/Pythonwin/pywin/Demos/ocx/webbrowser.py b/Pythonwin/pywin/Demos/ocx/webbrowser.py index f0716176d7..66c958ec38 100644 --- a/Pythonwin/pywin/Demos/ocx/webbrowser.py +++ b/Pythonwin/pywin/Demos/ocx/webbrowser.py @@ -35,7 +35,7 @@ def __init__(self, url=None): self.url = "https://www.python.org" else: self.url = url - pass # Don't call base class doc/view version... + # Don't call base class doc/view version... def Create(self, title, rect=None, parent=None): style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_OVERLAPPEDWINDOW diff --git a/Pythonwin/pywin/Demos/threadedgui.py b/Pythonwin/pywin/Demos/threadedgui.py index 917b3ad64f..cbfb5a6fc6 100644 --- a/Pythonwin/pywin/Demos/threadedgui.py +++ b/Pythonwin/pywin/Demos/threadedgui.py @@ -134,7 +134,7 @@ def ExitInstance(self): class ThreadedFontFrame(window.MDIChildWnd): def __init__(self): - pass # Don't call base class doc/view version... + # Don't call base class doc/view version... self.thread = None def Create(self, title, rect=None, parent=None): diff --git a/Pythonwin/pywin/debugger/dbgpyapp.py b/Pythonwin/pywin/debugger/dbgpyapp.py index 284460e87e..090835cf72 100644 --- a/Pythonwin/pywin/debugger/dbgpyapp.py +++ b/Pythonwin/pywin/debugger/dbgpyapp.py @@ -11,7 +11,7 @@ class DebuggerPythonApp(intpyapp.InteractivePythonApp): def LoadMainFrame(self): - "Create the main applications frame" + """Create the main applications frame""" self.frame = self.CreateMainFrame() self.SetMainFrame(self.frame) self.frame.LoadFrame(win32ui.IDR_DEBUGGER, win32con.WS_OVERLAPPEDWINDOW) diff --git a/Pythonwin/pywin/debugger/debugger.py b/Pythonwin/pywin/debugger/debugger.py index 72b9cf2dc4..62d44b1fdc 100644 --- a/Pythonwin/pywin/debugger/debugger.py +++ b/Pythonwin/pywin/debugger/debugger.py @@ -948,7 +948,7 @@ def GUIAboutToRun(self): return 1 def GUIAboutToBreak(self): - "Called as the GUI debugger is about to get context, and take control of the running program." + """Called as the GUI debugger is about to get context, and take control of the running program.""" self.GUICheckInit() self.RespondDebuggerState(DBGSTATE_BREAK) self.GUIAboutToInteract() @@ -962,7 +962,7 @@ def GUIAboutToBreak(self): win32ui.GetMainFrame().PostMessage(win32con.WM_CLOSE) def GUIAboutToInteract(self): - "Called as the GUI is about to perform any interaction with the user" + """Called as the GUI is about to perform any interaction with the user""" frame = win32ui.GetMainFrame() # Remember the enabled state of our main frame # may be disabled primarily if a modal dialog is displayed. @@ -1069,7 +1069,7 @@ def ShowCurrentLine(self): self.ShowLineState(fileName, lineNo, LINESTATE_CURRENT) def _UnshowCurrentLine(self): - "Unshow the current line, and forget it" + """Unshow the current line, and forget it""" if self.shownLineCurrent is not None: fname, lineno = self.shownLineCurrent self.ResetLineState(fname, lineno, LINESTATE_CURRENT) diff --git a/Pythonwin/pywin/framework/app.py b/Pythonwin/pywin/framework/app.py index f5b91119b3..8ec0412dcd 100644 --- a/Pythonwin/pywin/framework/app.py +++ b/Pythonwin/pywin/framework/app.py @@ -2,7 +2,7 @@ # The application is responsible for managing the main frame window. # # We also grab the FileOpen command, to invoke our Python editor -"The PythonWin application code. Manages most aspects of MDI, etc" +"""The PythonWin application code. Manages most aspects of MDI, etc""" from __future__ import annotations @@ -113,7 +113,7 @@ def OnDestroy(self, msg): class CApp(WinApp): - "A class for the application" + """A class for the application""" def __init__(self): self.oldCallbackCaller = None @@ -121,7 +121,7 @@ def __init__(self): self.idleHandlers = [] def InitInstance(self): - "Called to crank up the app" + """Called to crank up the app""" HookInput() numMRU = win32ui.GetProfileVal("Settings", "Recent File List Size", 10) win32ui.LoadStdProfileSettings(numMRU) @@ -133,7 +133,7 @@ def InitInstance(self): self.SetApplicationPaths() def ExitInstance(self): - "Called as the app dies - too late to prevent it here!" + """Called as the app dies - too late to prevent it here!""" win32ui.OutputDebug("Application shutdown\n") # Restore the callback manager, if any. try: @@ -184,7 +184,7 @@ def CreateMainFrame(self): return MainFrame() def LoadMainFrame(self): - "Create the main applications frame" + """Create the main applications frame""" self.frame = self.CreateMainFrame() self.SetMainFrame(self.frame) self.frame.LoadFrame(win32ui.IDR_MAINFRAME, win32con.WS_OVERLAPPEDWINDOW) @@ -250,19 +250,19 @@ def SetApplicationPaths(self): sys.path = new_path + sys.path def OnRClick(self, params): - "Handle right click message" + """Handle right click message""" # put up the entire FILE menu! menu = win32ui.LoadMenu(win32ui.IDR_TEXTTYPE).GetSubMenu(0) menu.TrackPopupMenu(params[5]) # track at mouse position. return 0 def OnDropFiles(self, msg): - "Handle a file being dropped from file manager" + """Handle a file being dropped from file manager""" hDropInfo = msg[2] self.frame.SetActiveWindow() # active us nFiles = win32api.DragQueryFile(hDropInfo) try: - for iFile in range(0, nFiles): + for iFile in range(nFiles): fileName = win32api.DragQueryFile(hDropInfo, iFile) win32ui.GetApp().OpenDocumentFile(fileName) finally: @@ -294,20 +294,20 @@ def OnDropFiles(self, msg): # Command handlers. def OnFileMRU(self, id, code): - "Called when a File 1-n message is received" + """Called when a File 1-n message is received""" fileName = win32ui.GetRecentFileList()[id - win32ui.ID_FILE_MRU_FILE1] win32ui.GetApp().OpenDocumentFile(fileName) def HandleOnFileOpen(self, id, code): - "Called when FileOpen message is received" + """Called when FileOpen message is received""" win32ui.GetApp().OnFileOpen() def HandleOnFileNew(self, id, code): - "Called when FileNew message is received" + """Called when FileNew message is received""" win32ui.GetApp().OnFileNew() def OnHelpAbout(self, id, code): - "Called when HelpAbout message is received. Displays the About dialog." + """Called when HelpAbout message is received. Displays the About dialog.""" win32ui.InitRichEdit() dlg = AboutBox() dlg.DoModal() @@ -365,7 +365,7 @@ def OnButHomePage(self, id, code): def Win32Input(prompt=None): - "Provide input() for gui apps" + """Provide input() for gui apps""" # flush stderr/out first. try: sys.stdout.flush() diff --git a/Pythonwin/pywin/framework/bitmap.py b/Pythonwin/pywin/framework/bitmap.py index dd8c085a08..f969aa877a 100644 --- a/Pythonwin/pywin/framework/bitmap.py +++ b/Pythonwin/pywin/framework/bitmap.py @@ -10,7 +10,7 @@ class BitmapDocument(docview.Document): - "A bitmap document. Holds the bitmap data itself." + """A bitmap document. Holds the bitmap data itself.""" def __init__(self, template): docview.Document.__init__(self, template) @@ -40,7 +40,7 @@ def DeleteContents(self): class BitmapView(docview.ScrollView): - "A view of a bitmap. Obtains data from document." + """A view of a bitmap. Obtains data from document.""" def __init__(self, doc): docview.ScrollView.__init__(self, doc) diff --git a/Pythonwin/pywin/framework/dlgappcore.py b/Pythonwin/pywin/framework/dlgappcore.py index 80261c32fc..309e133948 100644 --- a/Pythonwin/pywin/framework/dlgappcore.py +++ b/Pythonwin/pywin/framework/dlgappcore.py @@ -12,7 +12,7 @@ class AppDialog(dialog.Dialog): - "The dialog box for the application" + """The dialog box for the application""" def __init__(self, id, dll=None): self.iconId = win32ui.IDR_MAINFRAME @@ -49,7 +49,7 @@ def PreDoModal(self): class DialogApp(app.CApp): - "An application class, for an app with main dialog box" + """An application class, for an app with main dialog box""" def InitInstance(self): # win32ui.SetProfileFileName('dlgapp.ini') diff --git a/Pythonwin/pywin/framework/editor/color/coloreditor.py b/Pythonwin/pywin/framework/editor/color/coloreditor.py index d2a78e69db..cf9e9d64f4 100644 --- a/Pythonwin/pywin/framework/editor/color/coloreditor.py +++ b/Pythonwin/pywin/framework/editor/color/coloreditor.py @@ -24,7 +24,7 @@ class SyntEditDocument(EditorDocumentBase): - "A SyntEdit document." + """A SyntEdit document.""" def OnDebuggerStateChange(self, state): self._ApplyOptionalToViews("OnDebuggerStateChange", state) @@ -40,7 +40,7 @@ def FinalizeViewCreation(self, view): class SyntEditView(SyntEditViewParent): - "A view of a SyntEdit. Obtains data from document." + """A view of a SyntEdit. Obtains data from document.""" def __init__(self, doc): SyntEditViewParent.__init__(self, doc) @@ -538,7 +538,7 @@ def FoldExpandAllEvent(self, event): if not self.bFolding: return 1 win32ui.DoWaitCursor(1) - for lineno in range(0, self.GetLineCount()): + for lineno in range(self.GetLineCount()): if self.SCIGetFoldLevel( lineno ) & scintillacon.SC_FOLDLEVELHEADERFLAG and not self.SCIGetFoldExpanded( @@ -563,7 +563,7 @@ def FoldCollapseAllEvent(self, event): return 1 win32ui.DoWaitCursor(1) self.Colorize() - for lineno in range(0, self.GetLineCount()): + for lineno in range(self.GetLineCount()): if self.SCIGetFoldLevel( lineno ) & scintillacon.SC_FOLDLEVELHEADERFLAG and self.SCIGetFoldExpanded(lineno): diff --git a/Pythonwin/pywin/framework/editor/editor.py b/Pythonwin/pywin/framework/editor/editor.py index a83f20312a..5535765309 100644 --- a/Pythonwin/pywin/framework/editor/editor.py +++ b/Pythonwin/pywin/framework/editor/editor.py @@ -154,7 +154,7 @@ def SetAllLineColors(self, color=None): view.SetAllLineColors(color) def SetLineColor(self, lineNo, color): - "Color a line of all views" + """Color a line of all views""" for view in self.GetAllViews(): view.SetLineColor(lineNo, color) @@ -200,7 +200,7 @@ def CutCurLine(self): self._obj_.Cut() def _PrepareUserStateChange(self): - "Return selection, lineindex, etc info, so it can be restored" + """Return selection, lineindex, etc info, so it can be restored""" self.SetRedraw(0) return self.GetModify(), self.GetSel(), self.GetFirstVisibleLine() @@ -229,7 +229,7 @@ def SetAllLineColors(self, color=None): self._EndUserStateChange(info) def SetLineColor(self, lineNo, color): - "lineNo is the 1 based line number to set. If color is None, default color is used." + """lineNo is the 1 based line number to set. If color is None, default color is used.""" if isRichText: info = self._PrepareUserStateChange() try: @@ -294,7 +294,7 @@ def Indent(self): self._obj_.ReplaceSel(ins) def BlockDent(self, isIndent, startLine, endLine): - "Indent/Undent all lines specified" + """Indent/Undent all lines specified""" if not self.GetDocument().CheckMakeDocumentWritable(): return 0 tabSize = self.tabSize # hard-code for now! @@ -312,7 +312,7 @@ def BlockDent(self, isIndent, startLine, endLine): if line[0] == "\t": noToDel = 1 elif line[0] == " ": - for noToDel in range(0, tabSize): + for noToDel in range(tabSize): if line[noToDel] != " ": break else: diff --git a/Pythonwin/pywin/framework/help.py b/Pythonwin/pywin/framework/help.py index 7467d2f8fb..69443c14df 100644 --- a/Pythonwin/pywin/framework/help.py +++ b/Pythonwin/pywin/framework/help.py @@ -30,7 +30,7 @@ def FinalizeHelp(): def OpenHelpFile(fileName, helpCmd=None, helpArg=None): - "Open a help file, given a full path" + """Open a help file, given a full path""" # default help arg. win32ui.DoWaitCursor(1) try: diff --git a/Pythonwin/pywin/framework/interact.py b/Pythonwin/pywin/framework/interact.py index c26bf6e829..4daa775e3b 100644 --- a/Pythonwin/pywin/framework/interact.py +++ b/Pythonwin/pywin/framework/interact.py @@ -388,7 +388,7 @@ def DoGetLine(self, line=-1): return line def AppendToPrompt(self, bufLines, oldPrompt=None): - "Take a command and stick it at the end of the buffer (with python prompts inserted if required)." + """Take a command and stick it at the end of the buffer (with python prompts inserted if required).""" self.flush() lastLineNo = self.GetLineCount() - 1 line = self.DoGetLine(lastLineNo) diff --git a/Pythonwin/pywin/framework/intpyapp.py b/Pythonwin/pywin/framework/intpyapp.py index c69fa184fd..763bbb61d9 100644 --- a/Pythonwin/pywin/framework/intpyapp.py +++ b/Pythonwin/pywin/framework/intpyapp.py @@ -404,7 +404,7 @@ def OnDDECommand(self, command): # General handlers # def OnViewBrowse(self, id, code): - "Called when ViewBrowse message is received" + """Called when ViewBrowse message is received""" from pywin.tools import browser obName = dialog.GetSimpleInput("Object", "__builtins__", "Browse Python Object") @@ -421,13 +421,13 @@ def OnViewBrowse(self, id, code): win32ui.MessageBox("This object can not be browsed") def OnFileImport(self, id, code): - "Called when a FileImport message is received. Import the current or specified file" + """Called when a FileImport message is received. Import the current or specified file""" from . import scriptutils scriptutils.ImportFile() def OnFileCheck(self, id, code): - "Called when a FileCheck message is received. Check the current file." + """Called when a FileCheck message is received. Check the current file.""" from . import scriptutils scriptutils.CheckFile() @@ -438,7 +438,7 @@ def OnUpdateFileCheck(self, cmdui): cmdui.Enable(scriptutils.GetActiveFileName(0) is not None) def OnFileRun(self, id, code): - "Called when a FileRun message is received." + """Called when a FileRun message is received.""" from . import scriptutils showDlg = win32api.GetKeyState(win32con.VK_SHIFT) >= 0 diff --git a/Pythonwin/pywin/framework/scriptutils.py b/Pythonwin/pywin/framework/scriptutils.py index abf5a40c13..90f7850973 100644 --- a/Pythonwin/pywin/framework/scriptutils.py +++ b/Pythonwin/pywin/framework/scriptutils.py @@ -36,7 +36,7 @@ # A dialog box for the "Run Script" command. class DlgRunScript(dialog.Dialog): - "A class for the 'run script' dialog" + """A class for the 'run script' dialog""" def __init__(self, bHaveDebugger): dialog.Dialog.__init__(self, win32ui.IDD_RUN_SCRIPT) @@ -86,7 +86,7 @@ def GetDebugger(): def IsOnPythonPath(path): - "Given a path only, see if it is on the Pythonpath. Assumes path is a full path spec." + """Given a path only, see if it is on the Pythonpath. Assumes path is a full path spec.""" # must check that the command line arg's path is in sys.path for syspath in sys.path: try: @@ -655,7 +655,7 @@ def FindTabNanny(): def LocatePythonFile(fileName, bBrowseIfDir=1): - "Given a file name, return a fully qualified file name, or None" + """Given a file name, return a fully qualified file name, or None""" # first look for the exact file as specified if not os.path.isfile(fileName): # Go looking! diff --git a/Pythonwin/pywin/framework/startup.py b/Pythonwin/pywin/framework/startup.py index ca7a44d874..51ef3012f7 100644 --- a/Pythonwin/pywin/framework/startup.py +++ b/Pythonwin/pywin/framework/startup.py @@ -1,6 +1,6 @@ # startup.py # -"The main application startup code for PythonWin." +"""The main application startup code for PythonWin.""" # # This does the basic command line handling. diff --git a/Pythonwin/pywin/framework/stdin.py b/Pythonwin/pywin/framework/stdin.py index b7d71dc19e..ada8ec9209 100644 --- a/Pythonwin/pywin/framework/stdin.py +++ b/Pythonwin/pywin/framework/stdin.py @@ -50,7 +50,7 @@ def read(self, size=-1): return self.__extract_from_buffer(result_size) def readline(self, size=-1): - """Read one entire line from the file. A trailing newline + r"""Read one entire line from the file. A trailing newline character is kept in the string2.6 (but may be absent when a file ends with an incomplete line). If the size argument is present and non-negative, it is a maximum byte count (including the trailing diff --git a/Pythonwin/pywin/framework/window.py b/Pythonwin/pywin/framework/window.py index 58fd4d9534..9bc69f3cc1 100644 --- a/Pythonwin/pywin/framework/window.py +++ b/Pythonwin/pywin/framework/window.py @@ -8,7 +8,7 @@ class MDIChildWnd(pywin.mfc.window.MDIChildWnd): def AutoRestore(self): - "If the window is minimised or maximised, restore it." + """If the window is minimised or maximised, restore it.""" p = self.GetWindowPlacement() if p[1] == win32con.SW_MINIMIZE or p[1] == win32con.SW_SHOWMINIMIZED: self.SetWindowPlacement(p[0], win32con.SW_RESTORE, p[2], p[3], p[4]) diff --git a/Pythonwin/pywin/idle/CallTips.py b/Pythonwin/pywin/idle/CallTips.py index 2e484db38e..e40bdeebda 100644 --- a/Pythonwin/pywin/idle/CallTips.py +++ b/Pythonwin/pywin/idle/CallTips.py @@ -158,46 +158,46 @@ def get_arg_text(ob): if __name__ == "__main__": def t1(): - "()" + """()""" def t2(a, b=None): - "(a, b=None)" + """(a, b=None)""" def t3(a, *args): - "(a, *args)" + """(a, *args)""" def t4(*args): - "(*args)" + """(*args)""" def t5(a, *args): - "(a, *args)" + """(a, *args)""" def t6(a, b=None, *args, **kw): - "(a, b=None, *args, **kw)" + """(a, b=None, *args, **kw)""" class TC: - "(self, a=None, *b)" + """(self, a=None, *b)""" def __init__(self, a=None, *b): - "(self, a=None, *b)" + """(self, a=None, *b)""" def t1(self): - "(self)" + """(self)""" def t2(self, a, b=None): - "(self, a, b=None)" + """(self, a, b=None)""" def t3(self, a, *args): - "(self, a, *args)" + """(self, a, *args)""" def t4(self, *args): - "(self, *args)" + """(self, *args)""" def t5(self, a, *args): - "(self, a, *args)" + """(self, a, *args)""" def t6(self, a, b=None, *args, **kw): - "(self, a, b=None, *args, **kw)" + """(self, a, b=None, *args, **kw)""" def test(tests): failed = [] diff --git a/Pythonwin/pywin/mfc/dialog.py b/Pythonwin/pywin/mfc/dialog.py index be4888a4c9..6d9d81c460 100644 --- a/Pythonwin/pywin/mfc/dialog.py +++ b/Pythonwin/pywin/mfc/dialog.py @@ -12,7 +12,7 @@ def dllFromDll(dllid): - "given a 'dll' (maybe a dll, filename, etc), return a DLL object" + """given a 'dll' (maybe a dll, filename, etc), return a DLL object""" if dllid is None: return None elif isinstance(dllid, str): @@ -26,7 +26,7 @@ def dllFromDll(dllid): class Dialog(window.Wnd): - "Base class for a dialog" + """Base class for a dialog""" def __init__(self, id, dllid=None): """id is the resource ID, or a template @@ -97,7 +97,7 @@ def __contains__(self, key): class PrintDialog(Dialog): - "Base class for a print dialog" + """Base class for a print dialog""" def __init__( self, @@ -185,7 +185,7 @@ def OnOK(self): class PropertyPage(Dialog): - "Base class for a Property Page" + """Base class for a Property Page""" def __init__(self, id, dllid=None, caption=0): """id is the resource ID @@ -207,7 +207,7 @@ def __init__(self, id, dllid=None, caption=0): class PropertySheet(window.Wnd): def __init__(self, caption, dll=None, pageList=None): # parent=None, style,etc): - "Initialize a property sheet. pageList is a list of ID's" + """Initialize a property sheet. pageList is a list of ID's""" # must take a reference to the DLL until InitDialog. self.dll = dllFromDll(dll) self.sheet = win32ui.CreatePropertySheet(caption) @@ -243,7 +243,7 @@ def AddPage(self, pages): win32ui.SetResource(oldRes) def DoAddSinglePage(self, page): - "Page may be page, or int ID. Assumes DLL setup" + """Page may be page, or int ID. Assumes DLL setup""" if isinstance(page, int): self.sheet.AddPage(win32ui.CreatePropertyPage(page)) else: diff --git a/Pythonwin/pywin/mfc/docview.py b/Pythonwin/pywin/mfc/docview.py index 7da91b460d..b520a1f53f 100644 --- a/Pythonwin/pywin/mfc/docview.py +++ b/Pythonwin/pywin/mfc/docview.py @@ -62,7 +62,7 @@ def __init__(self, template): class CreateContext: - "A transient base class used as a CreateContext" + """A transient base class used as a CreateContext""" def __init__(self, template, doc=None): self.template = template diff --git a/Pythonwin/pywin/scintilla/bindings.py b/Pythonwin/pywin/scintilla/bindings.py index 76b7739e6e..2095ffbd32 100644 --- a/Pythonwin/pywin/scintilla/bindings.py +++ b/Pythonwin/pywin/scintilla/bindings.py @@ -81,7 +81,7 @@ def bind(self, event, handler, handler_args_type=HANDLER_ARGS_GUESS, cid=0): self.bind_command(event, cid) def bind_command(self, event, id=0): - "Binds an event to a Windows control/command ID" + """Binds an event to a Windows control/command ID""" id = assign_command_id(event, id) return id diff --git a/Pythonwin/pywin/scintilla/document.py b/Pythonwin/pywin/scintilla/document.py index 065aa9b48a..d99812dc47 100644 --- a/Pythonwin/pywin/scintilla/document.py +++ b/Pythonwin/pywin/scintilla/document.py @@ -20,7 +20,7 @@ class CScintillaDocument(ParentScintillaDocument): - "A SyntEdit document." + """A SyntEdit document.""" def __init__(self, *args): self.bom = None # the BOM, if any, read from the file. diff --git a/Pythonwin/pywin/scintilla/view.py b/Pythonwin/pywin/scintilla/view.py index 918d0730e7..a1c70d267f 100644 --- a/Pythonwin/pywin/scintilla/view.py +++ b/Pythonwin/pywin/scintilla/view.py @@ -501,7 +501,7 @@ def _AutoComplete(self): # The object might be a pure COM dynamic dispatch with typelib support - let's see if we can get its props. if hasattr(ob, "_oleobj_"): try: - for iTI in range(0, ob._oleobj_.GetTypeInfoCount()): + for iTI in range(ob._oleobj_.GetTypeInfoCount()): typeInfo = ob._oleobj_.GetTypeInfo(iTI) self._UpdateWithITypeInfo(items_dict, typeInfo) except: @@ -572,7 +572,7 @@ def _UpdateWithITypeInfo(self, items_dict, typeInfo): if typeAttr.iid not in inspectedIIDs: inspectedIIDs[typeAttr.iid] = None - for iFun in range(0, typeAttr.cFuncs): + for iFun in range(typeAttr.cFuncs): funDesc = typeInfo.GetFuncDesc(iFun) funName = typeInfo.GetNames(funDesc.memid)[0] if funName not in items_dict: @@ -580,7 +580,7 @@ def _UpdateWithITypeInfo(self, items_dict, typeInfo): # Inspect the type info of all implemented types # E.g. IShellDispatch5 implements IShellDispatch4 which implements IShellDispatch3 ... - for iImplType in range(0, typeAttr.cImplTypes): + for iImplType in range(typeAttr.cImplTypes): iRefType = typeInfo.GetRefTypeOfImplType(iImplType) refTypeInfo = typeInfo.GetRefTypeInfo(iRefType) typeInfos.append(refTypeInfo) diff --git a/Pythonwin/pywin/tools/browser.py b/Pythonwin/pywin/tools/browser.py index b5629dc065..863fc3b3d5 100644 --- a/Pythonwin/pywin/tools/browser.py +++ b/Pythonwin/pywin/tools/browser.py @@ -401,7 +401,7 @@ def on_size(self, params): def Browse(ob=__main__): - "Browse the argument, or the main dictionary" + """Browse the argument, or the main dictionary""" root = MakeHLI(ob, "root") if not root.IsExpandable(): raise TypeError( diff --git a/Pythonwin/pywin/tools/regpy.py b/Pythonwin/pywin/tools/regpy.py index 2dfe228d81..7ba8b15fa0 100644 --- a/Pythonwin/pywin/tools/regpy.py +++ b/Pythonwin/pywin/tools/regpy.py @@ -13,7 +13,7 @@ class RegEditPropertyPage(dialog.PropertyPage): IDC_LISTVIEW = 1000 def GetTemplate(self): - "Return the template used to create this dialog" + """Return the template used to create this dialog""" w = 152 # Dialog width h = 122 # Dialog height diff --git a/adodbapi/__init__.py b/adodbapi/__init__.py index 6ab125fe39..1a6709d4ce 100644 --- a/adodbapi/__init__.py +++ b/adodbapi/__init__.py @@ -44,17 +44,17 @@ def Binary(aString): def Date(year, month, day): - "This function constructs an object holding a date value." + """This function constructs an object holding a date value.""" return dateconverter.Date(year, month, day) def Time(hour, minute, second): - "This function constructs an object holding a time value." + """This function constructs an object holding a time value.""" return dateconverter.Time(hour, minute, second) def Timestamp(year, month, day, hour, minute, second): - "This function constructs an object holding a time stamp value." + """This function constructs an object holding a time stamp value.""" return dateconverter.Timestamp(year, month, day, hour, minute, second) diff --git a/adodbapi/adodbapi.py b/adodbapi/adodbapi.py index cbc0c0f0e1..be0329322a 100644 --- a/adodbapi/adodbapi.py +++ b/adodbapi/adodbapi.py @@ -227,7 +227,7 @@ class Connection: @property def dbapi(self): # a proposed db-api version 3 extension. - "Return a reference to the DBAPI module for this Connection." + """Return a reference to the DBAPI module for this Connection.""" return api def __init__(self): # now define the instance attributes @@ -439,18 +439,18 @@ def __getattr__(self, item): ) def cursor(self): - "Return a new Cursor Object using the connection." + """Return a new Cursor Object using the connection.""" self.messages = [] c = Cursor(self) return c def _i_am_here(self, crsr): - "message from a new cursor proclaiming its existence" + """message from a new cursor proclaiming its existence""" oid = id(crsr) self.cursors[oid] = crsr def _i_am_closing(self, crsr): - "message from a cursor giving connection a chance to clean up" + """message from a cursor giving connection a chance to clean up""" try: del self.cursors[id(crsr)] except: @@ -580,11 +580,11 @@ def __next__(self): raise StopIteration def __enter__(self): - "Allow database cursors to be used with context managers." + """Allow database cursors to be used with context managers.""" return self def __exit__(self, exc_type, exc_val, exc_tb): - "Allow database cursors to be used with context managers." + """Allow database cursors to be used with context managers.""" self.close() def _raiseCursorError(self, errorclass, errorvalue): @@ -855,7 +855,6 @@ def _buildADOparameterList(self, parameters, sproc=False): except api.Error: if verbose: print("ADO Parameter Refresh failed") - pass else: if len(parameters) != self.cmd.Parameters.Count - 1: raise api.ProgrammingError( diff --git a/adodbapi/apibase.py b/adodbapi/apibase.py index 87a5317eb8..02ec431e36 100644 --- a/adodbapi/apibase.py +++ b/adodbapi/apibase.py @@ -87,7 +87,6 @@ class FetchFailedError(OperationalError): returned. (Non-standard, added especially for django) """ - pass # # # # # ----- Type Objects and Constructors ----- # # # # # @@ -183,24 +182,24 @@ def ComDateFromTuple(self, t, microseconds=0): return integerPart + fractPart def DateObjectFromCOMDate(self, comDate): - "Returns an object of the wanted type from a ComDate" + """Returns an object of the wanted type from a ComDate""" raise NotImplementedError # "Abstract class" def Date(self, year, month, day): - "This function constructs an object holding a date value." + """This function constructs an object holding a date value.""" raise NotImplementedError # "Abstract class" def Time(self, hour, minute, second): - "This function constructs an object holding a time value." + """This function constructs an object holding a time value.""" raise NotImplementedError # "Abstract class" def Timestamp(self, year, month, day, hour, minute, second): - "This function constructs an object holding a time stamp value." + """This function constructs an object holding a time stamp value.""" raise NotImplementedError # "Abstract class" # all purpose date to ISO format converter def DateObjectToIsoFormatString(self, obj): - "This function should return a string in the format 'YYYY-MM-dd HH:MM:SS:ms' (ms optional)" + """This function should return a string in the format 'YYYY-MM-dd HH:MM:SS:ms' (ms optional)""" try: # most likely, a datetime.datetime s = obj.isoformat(" ") except (TypeError, AttributeError): @@ -253,7 +252,7 @@ def __init__(self): # caution: this Class gets confused by timezones and DST self.types.add(time.struct_time) def DateObjectFromCOMDate(self, comDate): - "Returns ticks since 1970" + """Returns ticks since 1970""" if isinstance(comDate, datetime.datetime): return comDate.timetuple() else: @@ -477,7 +476,7 @@ def __init__(self, aDict: Mapping[Iterable[int] | int, Callable[[object], object def __setitem__( self, adoType: Iterable[int] | int, cvtFn: Callable[[object], object] ): - "set a single item, or a whole iterable of items" + """set a single item, or a whole iterable of items""" if isinstance(adoType, Iterable): # user passed us an iterable, set them individually for type in adoType: diff --git a/adodbapi/examples/db_print.py b/adodbapi/examples/db_print.py index 33a6511388..8bf03c91d5 100644 --- a/adodbapi/examples/db_print.py +++ b/adodbapi/examples/db_print.py @@ -47,7 +47,7 @@ print( 'result rowcount shows as= %d. (Note: -1 means "not known")' % (c.rowcount,) ) - print("") + print() print("result data description is:") print(" NAME Type DispSize IntrnlSz Prec Scale Null?") for d in c.description: @@ -55,7 +55,7 @@ ("%16s %-12s %8s %8d %4d %5d %s") % (d[0], adc.adTypeNames[d[1]], d[2], d[3], d[4], d[5], bool(d[6])) ) - print("") + print() print("str() of first five records are...") # get the results @@ -65,8 +65,8 @@ for rec in db: print(rec) - print("") + print() print("repr() of next row is...") print(repr(c.fetchone())) - print("") + print() con.close() diff --git a/adodbapi/test/adodbapitest.py b/adodbapi/test/adodbapitest.py index 597d845e41..f5d4d3a857 100644 --- a/adodbapi/test/adodbapitest.py +++ b/adodbapi/test/adodbapitest.py @@ -42,7 +42,7 @@ def randomstring(length): class CommonDBTests(unittest.TestCase): - "Self contained super-simple tests in easy syntax, should work on everything between mySQL and Oracle" + """Self contained super-simple tests in easy syntax, should work on everything between mySQL and Oracle""" def setUp(self): self.engine = "unknown" @@ -1020,7 +1020,7 @@ def testSwitchedAutoCommit(self): def testExtendedTypeHandling(self): class XtendString(str): - pass + __slots__ = () class XtendInt(int): pass diff --git a/adodbapi/test/adodbapitestconfig.py b/adodbapi/test/adodbapitestconfig.py index 983480e4a4..5f6f7a574f 100644 --- a/adodbapi/test/adodbapitestconfig.py +++ b/adodbapi/test/adodbapitestconfig.py @@ -1,5 +1,5 @@ # Configure this to _YOUR_ environment in order to run the testcases. -"testADOdbapiConfig.py v 2.6.2.B00" +"""testADOdbapiConfig.py v 2.6.2.B00""" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # diff --git a/adodbapi/test/dbapi20.py b/adodbapi/test/dbapi20.py index b291e498e9..bcff529075 100644 --- a/adodbapi/test/dbapi20.py +++ b/adodbapi/test/dbapi20.py @@ -131,7 +131,6 @@ def setUp(self): """self.drivers should override this method to perform required setup if any is necessary, such as creating the database. """ - pass def tearDown(self): """self.drivers should override this method to perform required cleanup @@ -644,7 +643,7 @@ def test_fetchmany(self): rows.sort() # Make sure we get the right data back out - for i in range(0, 6): + for i in range(6): self.assertEqual( rows[i], self.samples[i], @@ -701,7 +700,7 @@ def test_fetchall(self): ) rows = [r[0] for r in rows] rows.sort() - for i in range(0, len(self.samples)): + for i in range(len(self.samples)): self.assertEqual( rows[i], self.samples[i], "cursor.fetchall retrieved incorrect rows" ) @@ -754,7 +753,7 @@ def test_mixedfetch(self): rows.append(rows4[0]) rows.extend([rows56[0][0], rows56[1][0]]) rows.sort() - for i in range(0, len(self.samples)): + for i in range(len(self.samples)): self.assertEqual( rows[i], self.samples[i], "incorrect data retrieved or inserted" ) @@ -777,7 +776,7 @@ def help_nextset_setUp(self, cur): # cur.execute(sql) def help_nextset_tearDown(self, cur): - "If cleaning up is needed after nextSetTest" + """If cleaning up is needed after nextSetTest""" raise NotImplementedError("Helper not implemented") # cur.execute("drop procedure deleteme") diff --git a/adodbapi/test/setuptestframework.py b/adodbapi/test/setuptestframework.py index 57d709c1f1..fc279993f7 100644 --- a/adodbapi/test/setuptestframework.py +++ b/adodbapi/test/setuptestframework.py @@ -1,6 +1,6 @@ #!/usr/bin/python2 # Configure this in order to run the testcases. -"setuptestframework.py v 2.6.0.8" +"""setuptestframework.py v 2.6.0.8""" import os import shutil diff --git a/adodbapi/test/test_adodbapi_dbapi20.py b/adodbapi/test/test_adodbapi_dbapi20.py index 201c6d8704..5201a01b12 100644 --- a/adodbapi/test/test_adodbapi_dbapi20.py +++ b/adodbapi/test/test_adodbapi_dbapi20.py @@ -135,7 +135,7 @@ def tearDown(self): dbapi20.DatabaseAPI20Test.tearDown(self) def help_nextset_setUp(self, cur): - "Should create a procedure called deleteme" + """Should create a procedure called deleteme""" 'that returns two result sets, first the number of rows in booze then "name from booze"' sql = """ create procedure deleteme as @@ -150,7 +150,7 @@ def help_nextset_setUp(self, cur): cur.execute(sql) def help_nextset_tearDown(self, cur): - "If cleaning up is needed after nextSetTest" + """If cleaning up is needed after nextSetTest""" try: cur.execute("drop procedure deleteme") except: diff --git a/com/win32com/client/build.py b/com/win32com/client/build.py index b4c5e75699..7691cf1fb2 100644 --- a/com/win32com/client/build.py +++ b/com/win32com/client/build.py @@ -70,7 +70,7 @@ class NotSupportedException(Exception): class MapEntry: - "Simple holder for named attibutes - items in a map." + """Simple holder for named attibutes - items in a map.""" def __init__( self, @@ -322,7 +322,7 @@ def Build(self, typeinfo, attr, bForUser=1): self._propMapPutCheck_(key, item) def CountInOutOptArgs(self, argTuple): - "Return tuple counting in/outs/OPTS. Sum of result may not be len(argTuple), as some args may be in/out." + """Return tuple counting in/outs/OPTS. Sum of result may not be len(argTuple), as some args may be in/out.""" ins = out = opts = 0 for argCheck in argTuple: inOut = argCheck[1] @@ -598,7 +598,7 @@ def _ResolveType(typerepr, itypeinfo): def _BuildArgList(fdesc, names): - "Builds list of args to the underlying Invoke method." + """Builds list of args to the underlying Invoke method.""" # Word has TypeInfo for Insert() method, but says "no args" numArgs = max(fdesc[6], len(fdesc[2])) names = list(names) @@ -713,7 +713,7 @@ def BuildCallList( defOutArg, is_comment=False, ): - "Builds a Python declaration for a method." + """Builds a Python declaration for a method.""" # Names[0] is the func name - param names are from 1. numArgs = len(fdesc[2]) numOptArgs = fdesc[6] diff --git a/com/win32com/client/combrowse.py b/com/win32com/client/combrowse.py index 8ba479d404..b6a3df9ab6 100644 --- a/com/win32com/client/combrowse.py +++ b/com/win32com/client/combrowse.py @@ -114,7 +114,7 @@ def GetSubList(self): class HLIHeadingCategory(HLICOM): - "A tree heading for registered categories" + """A tree heading for registered categories""" def GetText(self): return "Registered Categories" @@ -138,7 +138,7 @@ def GetSubList(self): class HLICategory(HLICOM): - "An actual Registered Category" + """An actual Registered Category""" def GetText(self): desc = self.myobject[2] @@ -533,7 +533,7 @@ def GetSubList(self): class HLIHeadingRegisterdTypeLibs(HLICOM): - "A tree heading for registered type libraries" + """A tree heading for registered type libraries""" def GetText(self): return "Registered Type Libraries" diff --git a/com/win32com/client/connect.py b/com/win32com/client/connect.py index 0bdd1f75a7..74e7124064 100644 --- a/com/win32com/client/connect.py +++ b/com/win32com/client/connect.py @@ -6,7 +6,7 @@ class SimpleConnection: - "A simple, single connection object" + """A simple, single connection object""" def __init__(self, coInstance=None, eventInstance=None, eventCLSID=None, debug=0): self.cp = None diff --git a/com/win32com/client/dynamic.py b/com/win32com/client/dynamic.py index 3738da9031..42fc683f6f 100644 --- a/com/win32com/client/dynamic.py +++ b/com/win32com/client/dynamic.py @@ -177,7 +177,7 @@ def DumbDispatch( createClass=None, clsctx=pythoncom.CLSCTX_SERVER, ): - "Dispatch with no type info" + """Dispatch with no type info""" IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch, userName, clsctx) if createClass is None: createClass = CDispatch @@ -198,7 +198,7 @@ def __init__(self, IDispatch, olerepr, userName=None, lazydata=None): self.__dict__["_lazydata_"] = lazydata def __call__(self, *args): - "Provide 'default dispatch' COM functionality - allow instance to be called" + """Provide 'default dispatch' COM functionality - allow instance to be called""" if self._olerepr_.defaultDispatchName: invkind, dispid = self._find_dispatch_type_( self._olerepr_.defaultDispatchName @@ -243,7 +243,7 @@ def __dir__(self): def _dir_ole_(self): items_dict = {} - for iTI in range(0, self._oleobj_.GetTypeInfoCount()): + for iTI in range(self._oleobj_.GetTypeInfoCount()): typeInfo = self._oleobj_.GetTypeInfo(iTI) self._UpdateWithITypeInfo_(items_dict, typeInfo) return list(items_dict) @@ -259,7 +259,7 @@ def _UpdateWithITypeInfo_(self, items_dict, typeInfo): if typeAttr.iid not in inspectedIIDs: inspectedIIDs[typeAttr.iid] = None - for iFun in range(0, typeAttr.cFuncs): + for iFun in range(typeAttr.cFuncs): funDesc = typeInfo.GetFuncDesc(iFun) funName = typeInfo.GetNames(funDesc.memid)[0] if funName not in items_dict: @@ -267,7 +267,7 @@ def _UpdateWithITypeInfo_(self, items_dict, typeInfo): # Inspect the type info of all implemented types # E.g. IShellDispatch5 implements IShellDispatch4 which implements IShellDispatch3 ... - for iImplType in range(0, typeAttr.cImplTypes): + for iImplType in range(typeAttr.cImplTypes): iRefType = typeInfo.GetRefTypeOfImplType(iImplType) refTypeInfo = typeInfo.GetRefTypeInfo(iRefType) typeInfos.append(refTypeInfo) @@ -400,7 +400,7 @@ def _get_good_object_(self, ob, userName=None, ReturnCLSID=None): return self._get_good_single_object_(ob) def _make_method_(self, name): - "Make a method object - Assumes in olerepr funcmap" + """Make a method object - Assumes in olerepr funcmap""" methodName = build.MakePublicAttributeName(name) # translate keywords etc. methodCodeList = self._olerepr_.MakeFuncMethod( self._olerepr_.mapFuncs[name], methodName, 0 @@ -453,7 +453,7 @@ def _proc_(self, name, *args): raise AttributeError(name) def _print_details_(self): - "Debug routine - dumps what it knows about an object." + """Debug routine - dumps what it knows about an object.""" print("AxDispatch container", self._username_) try: print("Methods:") diff --git a/com/win32com/client/genpy.py b/com/win32com/client/genpy.py index d53672dc52..bb48fd854c 100644 --- a/com/win32com/client/genpy.py +++ b/com/win32com/client/genpy.py @@ -1219,7 +1219,7 @@ def do_generate(self): print(file=stream) def generate_child(self, child, dir): - "Generate a single child. May force a few children to be built as we generate deps" + """Generate a single child. May force a few children to be built as we generate deps""" self.generate_type = GEN_DEMAND_CHILD la = self.typelib.GetLibAttr() diff --git a/com/win32com/client/tlbrowse.py b/com/win32com/client/tlbrowse.py index ceeabe8ec4..0ff9af017f 100644 --- a/com/win32com/client/tlbrowse.py +++ b/com/win32com/client/tlbrowse.py @@ -7,7 +7,7 @@ class TLBrowserException(Exception): - "TypeLib browser internal error" + """TypeLib browser internal error""" error = TLBrowserException # Re-exported alias @@ -36,7 +36,7 @@ class TLBrowserException(Exception): class TypeBrowseDialog(TypeBrowseDialog_Parent): - "Browse a type library" + """Browse a type library""" IDC_TYPELIST = 1000 IDC_MEMBERLIST = 1001 @@ -223,7 +223,7 @@ def CmdMemberListbox(self, id, code): return 1 def GetTemplate(self): - "Return the template used to create this dialog" + """Return the template used to create this dialog""" w = 272 # Dialog width h = 192 # Dialog height diff --git a/com/win32com/demos/excelRTDServer.py b/com/win32com/demos/excelRTDServer.py index deae3cb6d1..c4100759a5 100644 --- a/com/win32com/demos/excelRTDServer.py +++ b/com/win32com/demos/excelRTDServer.py @@ -241,23 +241,18 @@ def CreateTopic(self, TopicStrings=None): # Overridable class events... def OnConnectData(self, TopicID): """Called when a new topic has been created, at excel's request.""" - pass def OnDisconnectData(self, TopicID): """Called when a topic is about to be deleted, at excel's request.""" - pass def OnRefreshData(self): """Called when excel has requested all current topic data.""" - pass def OnServerStart(self): """Called when excel has instanciated us.""" - pass def OnServerTerminate(self): """Called when excel is about to destroy us.""" - pass class RTDTopic: diff --git a/com/win32com/makegw/makegwparse.py b/com/win32com/makegw/makegwparse.py index 34ef8e85eb..569349b46a 100644 --- a/com/win32com/makegw/makegwparse.py +++ b/com/win32com/makegw/makegwparse.py @@ -84,11 +84,11 @@ def GetIndirectedArgName(self, indirectFrom, indirectionTo): return self._IndirectPrefix(indirectFrom, indirectionTo) + self.arg.name def GetBuildValueArg(self): - "Get the argument to be passes to Py_BuildValue" + """Get the argument to be passes to Py_BuildValue""" return self.arg.name def GetParseTupleArg(self): - "Get the argument to be passed to PyArg_ParseTuple" + """Get the argument to be passed to PyArg_ParseTuple""" if self.gatewayMode: # use whatever they were declared with return self.GetIndirectedArgName(None, 1) @@ -127,7 +127,7 @@ def GetInterfaceCppObjectInfo(self): ) def GetInterfaceArgCleanup(self): - "Return cleanup code for C++ args passed to the interface method." + """Return cleanup code for C++ args passed to the interface method.""" if DEBUG: return "/* GetInterfaceArgCleanup output goes here: %s */\n" % self.arg.name else: @@ -159,7 +159,7 @@ def _GetDeclaredIndirection(self): return self.declaredIndirection def DeclareParseArgTupleInputConverter(self): - "Declare the variable used as the PyArg_ParseTuple param for a gateway" + """Declare the variable used as the PyArg_ParseTuple param for a gateway""" # Only declare it?? # if self.arg.indirectionLevel==0: # return "\t%s %s;\n" % (self.arg.type, self.arg.name) @@ -173,21 +173,21 @@ def DeclareParseArgTupleInputConverter(self): return "" def GetParsePostCode(self): - "Get a string of C++ code to be executed after (ie, to finalise) the PyArg_ParseTuple conversion" + """Get a string of C++ code to be executed after (ie, to finalise) the PyArg_ParseTuple conversion""" if DEBUG: return "/* GetParsePostCode code goes here: %s */\n" % self.arg.name else: return "" def GetBuildForInterfacePreCode(self): - "Get a string of C++ code to be executed before (ie, to initialise) the Py_BuildValue conversion for Interfaces" + """Get a string of C++ code to be executed before (ie, to initialise) the Py_BuildValue conversion for Interfaces""" if DEBUG: return "/* GetBuildForInterfacePreCode goes here: %s */\n" % self.arg.name else: return "" def GetBuildForGatewayPreCode(self): - "Get a string of C++ code to be executed before (ie, to initialise) the Py_BuildValue conversion for Gateways" + """Get a string of C++ code to be executed before (ie, to initialise) the Py_BuildValue conversion for Gateways""" s = self.GetBuildForInterfacePreCode() # Usually the same if DEBUG: if s[:4] == "/* G": @@ -195,13 +195,13 @@ def GetBuildForGatewayPreCode(self): return s def GetBuildForInterfacePostCode(self): - "Get a string of C++ code to be executed after (ie, to finalise) the Py_BuildValue conversion for Interfaces" + """Get a string of C++ code to be executed after (ie, to finalise) the Py_BuildValue conversion for Interfaces""" if DEBUG: return "/* GetBuildForInterfacePostCode goes here: %s */\n" % self.arg.name return "" def GetBuildForGatewayPostCode(self): - "Get a string of C++ code to be executed after (ie, to finalise) the Py_BuildValue conversion for Gateways" + """Get a string of C++ code to be executed after (ie, to finalise) the Py_BuildValue conversion for Gateways""" s = self.GetBuildForInterfacePostCode() # Usually the same if DEBUG: if s[:4] == "/* G": @@ -216,11 +216,11 @@ def GetAutoduckString(self): ) def _GetPythonTypeDesc(self): - "Returns a string with the description of the type. Used for doco purposes" + """Returns a string with the description of the type. Used for doco purposes""" return None def NeedUSES_CONVERSION(self): - "Determines if this arg forces a USES_CONVERSION macro" + """Determines if this arg forces a USES_CONVERSION macro""" return 0 diff --git a/com/win32com/server/register.py b/com/win32com/server/register.py index 817f3a28a2..0335a2f635 100644 --- a/com/win32com/server/register.py +++ b/com/win32com/server/register.py @@ -28,13 +28,13 @@ def _set_subkeys(keyName, valueDict, base=win32con.HKEY_CLASSES_ROOT): def _set_string(path, value, base=win32con.HKEY_CLASSES_ROOT): - "Set a string value in the registry." + """Set a string value in the registry.""" win32api.RegSetValue(base, path, win32con.REG_SZ, value) def _get_string(path, base=win32con.HKEY_CLASSES_ROOT): - "Get a string value from the registry." + """Get a string value from the registry.""" try: return win32api.RegQueryValue(base, path) @@ -43,7 +43,7 @@ def _get_string(path, base=win32con.HKEY_CLASSES_ROOT): def _remove_key(path, base=win32con.HKEY_CLASSES_ROOT): - "Remove a string from the registry." + """Remove a string from the registry.""" try: win32api.RegDeleteKey(base, path) diff --git a/com/win32com/server/util.py b/com/win32com/server/util.py index b75624d2d0..15190729c8 100644 --- a/com/win32com/server/util.py +++ b/com/win32com/server/util.py @@ -129,7 +129,7 @@ def NewEnum( class Collection: - "A collection of VARIANT values." + """A collection of VARIANT values.""" _public_methods_ = ["Item", "Count", "Add", "Remove", "Insert"] diff --git a/com/win32com/storagecon.py b/com/win32com/storagecon.py index 10ee65de43..ceb8748f88 100644 --- a/com/win32com/storagecon.py +++ b/com/win32com/storagecon.py @@ -1,4 +1,4 @@ -"""Constants related to IStorage and related interfaces +r"""Constants related to IStorage and related interfaces This file was generated by h2py from d:\\msdev\\include\\objbase.h then hand edited, a few extra constants added, etc. diff --git a/com/win32com/universal.py b/com/win32com/universal.py index c79d7d80a1..f23f214c3b 100644 --- a/com/win32com/universal.py +++ b/com/win32com/universal.py @@ -191,7 +191,7 @@ def dispatch( ReadFromInTuple=pythoncom._univgw.ReadFromInTuple, WriteFromOutTuple=pythoncom._univgw.WriteFromOutTuple, ): - "Dispatch a call to an interface method." + """Dispatch a call to an interface method.""" meth = self._methods[index] # Infer S_OK if they don't return anything bizarre. hr = 0 diff --git a/com/win32comext/adsi/demos/scp.py b/com/win32comext/adsi/demos/scp.py index dc5f831e8f..3e5351ed67 100644 --- a/com/win32comext/adsi/demos/scp.py +++ b/com/win32comext/adsi/demos/scp.py @@ -1,4 +1,4 @@ -"""A re-implementation of the MS DirectoryService samples related to services. +r"""A re-implementation of the MS DirectoryService samples related to services. * Adds and removes an ActiveDirectory "Service Connection Point", including managing the security on the object. diff --git a/com/win32comext/adsi/demos/test.py b/com/win32comext/adsi/demos/test.py index 5e7467c223..b4e75c76d7 100644 --- a/com/win32comext/adsi/demos/test.py +++ b/com/win32comext/adsi/demos/test.py @@ -12,7 +12,7 @@ def DumpRoot(): - "Dumps the root DSE" + """Dumps the root DSE""" path = "LDAP://%srootDSE" % server rootdse = ADsGetObject(path) @@ -55,7 +55,7 @@ def _DumpTheseAttributes(child, attrs): def DumpSchema(): - "Dumps the default DSE schema" + """Dumps the default DSE schema""" # Bind to rootDSE to get the schemaNamingContext property. path = "LDAP://%srootDSE" % server rootdse = ADsGetObject(path) @@ -112,7 +112,7 @@ def _DumpObject(ob, level=0): def DumpAllObjects(): - "Recursively dump the entire directory!" + """Recursively dump the entire directory!""" path = "LDAP://%srootDSE" % server rootdse = ADsGetObject(path) name = rootdse.Get("defaultNamingContext") @@ -139,7 +139,7 @@ def DumpAllObjects(): def DumpSchema2(): - "Dumps the schema using an alternative technique" + """Dumps the schema using an alternative technique""" path = f"LDAP://{server}schema" schema = ADsGetObject(path, IID_IADsContainer) nclass = nprop = nsyntax = 0 @@ -183,14 +183,14 @@ def DumpSchema2(): def DumpGC(): - "Dumps the GC: object (whatever that is!)" + """Dumps the GC: object (whatever that is!)""" ob = ADsGetObject("GC:", IID_IADsContainer) for sub_ob in ob: print(f"GC ob: {sub_ob.Name} ({sub_ob.ADsPath})") def DumpLocalUsers(): - "Dumps the local machine users" + """Dumps the local machine users""" path = f"WinNT://{local_name},computer" ob = ADsGetObject(path, IID_IADsContainer) ob.put_Filter(["User", "Group"]) @@ -199,7 +199,7 @@ def DumpLocalUsers(): def DumpLocalGroups(): - "Dumps the local machine groups" + """Dumps the local machine groups""" path = f"WinNT://{local_name},computer" ob = ADsGetObject(path, IID_IADsContainer) diff --git a/com/win32comext/axscript/client/debug.py b/com/win32comext/axscript/client/debug.py index 8e74d114fd..ad459ac075 100644 --- a/com/win32comext/axscript/client/debug.py +++ b/com/win32comext/axscript/client/debug.py @@ -95,7 +95,7 @@ def Close(self): # print("Close complete") def IsAnyHost(self): - "Do we have _any_ debugging interfaces installed?" + """Do we have _any_ debugging interfaces installed?""" return self.debugApplication is not None def IsSimpleHost(self): diff --git a/com/win32comext/axscript/client/pyscript.py b/com/win32comext/axscript/client/pyscript.py index 0e36029436..1e781c4cc4 100644 --- a/com/win32comext/axscript/client/pyscript.py +++ b/com/win32comext/axscript/client/pyscript.py @@ -55,7 +55,7 @@ def GetDisplayName(self): # This means that if 2 sub-objects of the same name are used # then only one is ever reachable using the ax shortcut. class AXScriptAttribute: - "An attribute in a scripts namespace." + """An attribute in a scripts namespace.""" def __init__(self, engine): self.__dict__["_scriptEngine_"] = engine @@ -99,7 +99,7 @@ def _FindAttribute_(self, attr): class NamedScriptAttribute: - "An explicitly named object in an objects namespace" + """An explicitly named object in an objects namespace""" # Each named object holds a reference to one of these. # Whenever a sub-item appears in a namespace, it is really one of these diff --git a/com/win32comext/directsound/test/ds_test.py b/com/win32comext/directsound/test/ds_test.py index 6307c34d61..55bbc2bc08 100644 --- a/com/win32comext/directsound/test/ds_test.py +++ b/com/win32comext/directsound/test/ds_test.py @@ -75,12 +75,12 @@ def wav_header_pack(wfx, datasize): class WAVEFORMATTest(unittest.TestCase): def test_1_Type(self): - "WAVEFORMATEX type" + """WAVEFORMATEX type""" w = pywintypes.WAVEFORMATEX() self.assertTrue(isinstance(w, pywintypes.WAVEFORMATEXType)) def test_2_Attr(self): - "WAVEFORMATEX attribute access" + """WAVEFORMATEX attribute access""" # A wav header for a soundfile from a CD should look like this... w = pywintypes.WAVEFORMATEX() w.wFormatTag = pywintypes.WAVE_FORMAT_PCM @@ -100,12 +100,12 @@ def test_2_Attr(self): class DSCAPSTest(unittest.TestCase): def test_1_Type(self): - "DSCAPS type" + """DSCAPS type""" c = ds.DSCAPS() self.assertTrue(isinstance(c, ds.DSCAPSType)) def test_2_Attr(self): - "DSCAPS attribute access" + """DSCAPS attribute access""" c = ds.DSCAPS() c.dwFlags = 1 c.dwMinSecondarySampleRate = 2 @@ -154,12 +154,12 @@ def test_2_Attr(self): class DSBCAPSTest(unittest.TestCase): def test_1_Type(self): - "DSBCAPS type" + """DSBCAPS type""" c = ds.DSBCAPS() self.assertTrue(isinstance(c, ds.DSBCAPSType)) def test_2_Attr(self): - "DSBCAPS attribute access" + """DSBCAPS attribute access""" c = ds.DSBCAPS() c.dwFlags = 1 c.dwBufferBytes = 2 @@ -174,12 +174,12 @@ def test_2_Attr(self): class DSCCAPSTest(unittest.TestCase): def test_1_Type(self): - "DSCCAPS type" + """DSCCAPS type""" c = ds.DSCCAPS() self.assertTrue(isinstance(c, ds.DSCCAPSType)) def test_2_Attr(self): - "DSCCAPS attribute access" + """DSCCAPS attribute access""" c = ds.DSCCAPS() c.dwFlags = 1 c.dwFormats = 2 @@ -192,12 +192,12 @@ def test_2_Attr(self): class DSCBCAPSTest(unittest.TestCase): def test_1_Type(self): - "DSCBCAPS type" + """DSCBCAPS type""" c = ds.DSCBCAPS() self.assertTrue(isinstance(c, ds.DSCBCAPSType)) def test_2_Attr(self): - "DSCBCAPS attribute access" + """DSCBCAPS attribute access""" c = ds.DSCBCAPS() c.dwFlags = 1 c.dwBufferBytes = 2 @@ -208,12 +208,12 @@ def test_2_Attr(self): class DSBUFFERDESCTest(unittest.TestCase): def test_1_Type(self): - "DSBUFFERDESC type" + """DSBUFFERDESC type""" c = ds.DSBUFFERDESC() self.assertTrue(isinstance(c, ds.DSBUFFERDESCType)) def test_2_Attr(self): - "DSBUFFERDESC attribute access" + """DSBUFFERDESC attribute access""" c = ds.DSBUFFERDESC() c.dwFlags = 1 c.dwBufferBytes = 2 @@ -238,19 +238,19 @@ def invalid_format(self, c): c.lpwfxFormat = 17 def test_3_invalid_format(self): - "DSBUFFERDESC invalid lpwfxFormat assignment" + """DSBUFFERDESC invalid lpwfxFormat assignment""" c = ds.DSBUFFERDESC() self.assertRaises(ValueError, self.invalid_format, c) class DSCBUFFERDESCTest(unittest.TestCase): def test_1_Type(self): - "DSCBUFFERDESC type" + """DSCBUFFERDESC type""" c = ds.DSCBUFFERDESC() self.assertTrue(isinstance(c, ds.DSCBUFFERDESCType)) def test_2_Attr(self): - "DSCBUFFERDESC attribute access" + """DSCBUFFERDESC attribute access""" c = ds.DSCBUFFERDESC() c.dwFlags = 1 c.dwBufferBytes = 2 @@ -275,7 +275,7 @@ def invalid_format(self, c): c.lpwfxFormat = 17 def test_3_invalid_format(self): - "DSCBUFFERDESC invalid lpwfxFormat assignment" + """DSCBUFFERDESC invalid lpwfxFormat assignment""" c = ds.DSCBUFFERDESC() self.assertRaises(ValueError, self.invalid_format, c) diff --git a/com/win32comext/shell/demos/servers/empty_volume_cache.py b/com/win32comext/shell/demos/servers/empty_volume_cache.py index 47dcc89a9f..8797e2994a 100644 --- a/com/win32comext/shell/demos/servers/empty_volume_cache.py +++ b/com/win32comext/shell/demos/servers/empty_volume_cache.py @@ -90,7 +90,7 @@ def _WalkCallback(self, arg, directory, files): callback, total_list = arg for file in files: fqn = os.path.join(directory, file).lower() - if file.endswith(".pyc") or file.endswith(".pyo"): + if file.endswith((".pyc", ".pyo")): # See below - total_list is None means delete files, # otherwise it is a list where the result is stored. It's a # list simply due to the way os.walk works - only [0] is diff --git a/isapi/install.py b/isapi/install.py index c4c61fb76c..b8dbdee4f3 100644 --- a/isapi/install.py +++ b/isapi/install.py @@ -83,7 +83,7 @@ def __init__(self, **kw): self.__dict__.update(kw) def is_root(self): - "This virtual directory is a root directory if parent and name are blank" + """This virtual directory is a root directory if parent and name are blank""" parent, name = self.split_path() return not parent and not name @@ -107,7 +107,7 @@ def __init__(self, **kw): self.__dict__.update(kw) def __str__(self): - "Format this parameter suitable for IIS" + """Format this parameter suitable for IIS""" items = [self.Extension, self.Module, self.Flags] # IIS gets upset if there is a trailing verb comma, but no verbs if self.Verbs: @@ -354,7 +354,7 @@ def AssignScriptMaps(script_maps, target, update="replace"): def get_unique_items(sequence, reference): - "Return items in sequence that can't be found in reference." + """Return items in sequence that can't be found in reference.""" return tuple([item for item in sequence if item not in reference]) @@ -577,7 +577,7 @@ def RemoveDirectory(params, options): def RemoveScriptMaps(vd_params, options): - "Remove script maps from the already installed virtual directory" + """Remove script maps from the already installed virtual directory""" parent, name = vd_params.split_path() target_dir = GetObject(FindPath(options, vd_params.Server, parent)) installed_maps = list(target_dir.ScriptMaps) @@ -660,7 +660,7 @@ def GetLoaderModuleName(mod_name: str, check_module=None): def InstallModule(conf_module_name, params, options, log=lambda *args: None): - "Install the extension" + """Install the extension""" if not hasattr(sys, "frozen"): conf_module_name = os.path.abspath(conf_module_name) if not os.path.isfile(conf_module_name): @@ -673,7 +673,7 @@ def InstallModule(conf_module_name, params, options, log=lambda *args: None): def UninstallModule(conf_module_name, params, options, log=lambda *args: None): - "Remove the extension" + """Remove the extension""" loader_dll = GetLoaderModuleName(conf_module_name, False) _PatchParamsModule(params, loader_dll, False) Uninstall(params, options) @@ -699,7 +699,6 @@ def MergeStandardOptions(options, params): Take an options object generated by the command line and merge the values into the IISParameters object. """ - pass # We support 2 ways of extending our command-line/install support. diff --git a/isapi/samples/advanced.py b/isapi/samples/advanced.py index 3cce5d885b..a8223aef29 100644 --- a/isapi/samples/advanced.py +++ b/isapi/samples/advanced.py @@ -111,7 +111,7 @@ def stop(self): # The ISAPI extension - handles requests in our virtual dir, and sends the # response to the client. class Extension(SimpleExtension): - "Python advanced sample Extension" + """Python advanced sample Extension""" def __init__(self): self.reload_watcher = ReloadWatcherThread() @@ -177,7 +177,7 @@ def PostInstall(params, options): # Handler for our custom 'status' argument. def status_handler(options, log, arg): - "Query the status of something" + """Query the status of something""" print("Everything seems to be fine!") diff --git a/isapi/samples/redirector.py b/isapi/samples/redirector.py index edf0e14456..dec8db78f1 100644 --- a/isapi/samples/redirector.py +++ b/isapi/samples/redirector.py @@ -50,7 +50,7 @@ def io_callback(ecb, url, cbIO, errcode): # The ISAPI extension - handles all requests in the site. class Extension(threaded_extension.ThreadPoolExtension): - "Python sample Extension" + """Python sample Extension""" def Dispatch(self, ecb): # Note that our ThreadPoolExtension base class will catch exceptions diff --git a/isapi/samples/redirector_asynch.py b/isapi/samples/redirector_asynch.py index b7c066fedd..906d18b845 100644 --- a/isapi/samples/redirector_asynch.py +++ b/isapi/samples/redirector_asynch.py @@ -38,7 +38,7 @@ def io_callback(ecb, fp, cbIO, errcode): # The ISAPI extension - handles all requests in the site. class Extension(threaded_extension.ThreadPoolExtension): - "Python sample proxy server - asynch version." + """Python sample proxy server - asynch version.""" def Dispatch(self, ecb): print('IIS dispatching "{}"'.format(ecb.GetServerVariable("URL"))) diff --git a/isapi/samples/redirector_with_filter.py b/isapi/samples/redirector_with_filter.py index af6356e6fd..5187e4fa92 100644 --- a/isapi/samples/redirector_with_filter.py +++ b/isapi/samples/redirector_with_filter.py @@ -58,7 +58,7 @@ # The ISAPI extension - handles requests in our virtual dir, and sends the # response to the client. class Extension(threaded_extension.ThreadPoolExtension): - "Python sample Extension" + """Python sample Extension""" def Dispatch(self, ecb): # Note that our ThreadPoolExtension base class will catch exceptions @@ -83,7 +83,7 @@ def Dispatch(self, ecb): # The ISAPI filter. class Filter(SimpleFilter): - "Sample Python Redirector" + """Sample Python Redirector""" filter_flags = isapicon.SF_NOTIFY_PREPROC_HEADERS | isapicon.SF_NOTIFY_ORDER_DEFAULT diff --git a/isapi/samples/test.py b/isapi/samples/test.py index 5e4d899bb6..2822fb0b03 100644 --- a/isapi/samples/test.py +++ b/isapi/samples/test.py @@ -67,7 +67,7 @@ def TransmitFileCallback(ecb, hFile, cbIO, errCode): # The ISAPI extension - handles requests in our virtual dir, and sends the # response to the client. class Extension(SimpleExtension): - "Python test Extension" + """Python test Extension""" def __init__(self): self.reload_watcher = ReloadWatcherThread() @@ -154,7 +154,7 @@ def PostInstall(params, options): # Handler for our custom 'status' argument. def status_handler(options, log, arg): - "Query the status of something" + """Query the status of something""" print("Everything seems to be fine!") diff --git a/isapi/simple.py b/isapi/simple.py index 177e8935cd..551648e018 100644 --- a/isapi/simple.py +++ b/isapi/simple.py @@ -12,7 +12,7 @@ class SimpleExtension: - "Base class for a simple ISAPI extension" + """Base class for a simple ISAPI extension""" def __init__(self): pass @@ -35,11 +35,10 @@ def HttpExtensionProc(self, control_block): def TerminateExtension(self, status): """Called by the ISAPI framework as the extension terminates.""" - pass class SimpleFilter: - "Base class for a a simple ISAPI filter" + """Base class for a a simple ISAPI filter""" filter_flags: int | None = None @@ -70,4 +69,3 @@ def HttpFilterProc(self, fc): def TerminateFilter(self, status): """Called by the ISAPI framework as the filter terminates.""" - pass diff --git a/isapi/test/extension_simple.py b/isapi/test/extension_simple.py index 32bd93b554..f9fee24b4b 100644 --- a/isapi/test/extension_simple.py +++ b/isapi/test/extension_simple.py @@ -23,7 +23,7 @@ # The ISAPI extension - handles requests in our virtual dir, and sends the # response to the client. class Extension(threaded_extension.ThreadPoolExtension): - "Python ISAPI Tester" + """Python ISAPI Tester""" def Dispatch(self, ecb): print('Tester dispatching "{}"'.format(ecb.GetServerVariable("URL"))) diff --git a/isapi/threaded_extension.py b/isapi/threaded_extension.py index a7fd17ff39..cd97269da6 100644 --- a/isapi/threaded_extension.py +++ b/isapi/threaded_extension.py @@ -61,7 +61,7 @@ def call_handler(self, cblock): # may leverage the CompletionPort to queue their own requests, and implement a # fully asynch extension. class ThreadPoolExtension(isapi.simple.SimpleExtension): - "Base class for an ISAPI extension based around a thread-pool" + """Base class for an ISAPI extension based around a thread-pool""" max_workers = 20 worker_shutdown_wait = 15000 # 15 seconds for workers to quit... diff --git a/ruff.toml b/ruff.toml index e96c2eafef..c198398bf4 100644 --- a/ruff.toml +++ b/ruff.toml @@ -9,26 +9,43 @@ line-ending = "cr-lf" select = [ "B028", # no-explicit-stacklevel "C4", # flake8-comprehensions + "D3", # pydocstyle docstring quotes + # "DTZ", + # "E", + # "F", "F811", # redefined-while-unused "I", # isort + # "LOG", + # "PERF", + "PIE", # flake8-pie "PLC", # Pylint Convention "PLE", # Pylint Error - "RSE", # flake8-raise + # PL + # "RET", + # "RUF", + "SIM", # flake8-simplify + "SLOT", + "T10", # flake8-debugger + # "TRY", "W", # pycodestyle Warning - "YTT", # flake8-2020 # String formatting, concatenating, interpolation, ... "FLY", # static-join-to-f-string "G", # flake8-logging-format + "ISC001", # single-line-implicit-string-concatenation # Ensure modern type annotation syntax and best practices # Not including those covered by type-checkers or exclusive to Python 3.11+ "FA", # flake8-future-annotations "F404", # late-future-import "PYI", # flake8-pyi + "PGH", # pygrep-hooks blanket-* # Code modernization (strings, annotations, conditions, ...) "UP", # pyupgrade + "FURB", # refurb + "RSE", # flake8-raise + "YTT", # flake8-2020 # Helps prevent circular imports and other unneeded imports "TC", # flake8-type-checking @@ -38,6 +55,7 @@ extend-ignore = [ "UP015", # redundant-open-modes # No such concerns for stdlib "TC003", # typing-only-standard-library-import + # "PERF203", # TODO: Consider passing exception around to ensure methods are only ever used within exception handlers "PLE0704", # misplaced-bare-raise # TODO: Still lots of manual fixes needed @@ -61,6 +79,11 @@ extend-ignore = [ "UP036", "YTT301", ] +"*/test/*" = [ + "SIM202", # Testing equality semantics (__neq__) + "SIM300", # Testing equality semantics (__req__) +] +"Pythonwin/pywin/debugger/*" = ["T10"] [lint.isort] combine-as-imports = true @@ -75,3 +98,6 @@ known-third-party = [ "distutils", ] extra-standard-library = ["setuptools"] + +[lint.flake8-implicit-str-concat] +allow-multiline = false diff --git a/win32/Demos/FileSecurityTest.py b/win32/Demos/FileSecurityTest.py index 4cb1aea2d7..ff89808591 100644 --- a/win32/Demos/FileSecurityTest.py +++ b/win32/Demos/FileSecurityTest.py @@ -48,7 +48,7 @@ if dacl is None: print("No Discretionary ACL") else: - for ace_no in range(0, dacl.GetAceCount()): + for ace_no in range(dacl.GetAceCount()): ace = dacl.GetAce(ace_no) print("ACE", ace_no) diff --git a/win32/Demos/security/sspi/socket_server.py b/win32/Demos/security/sspi/socket_server.py index dc26765270..dc40fc9d85 100644 --- a/win32/Demos/security/sspi/socket_server.py +++ b/win32/Demos/security/sspi/socket_server.py @@ -1,4 +1,4 @@ -"""A sample socket server and client using SSPI authentication and encryption. +r"""A sample socket server and client using SSPI authentication and encryption. You must run with either 'client' or 'server' as arguments. A server must be running before a client can connect. diff --git a/win32/Demos/win32netdemo.py b/win32/Demos/win32netdemo.py index 6b8750cedd..72b8454c01 100644 --- a/win32/Demos/win32netdemo.py +++ b/win32/Demos/win32netdemo.py @@ -19,7 +19,7 @@ def verbose(msg): def CreateUser(): - "Creates a new test user, then deletes the user" + """Creates a new test user, then deletes the user""" testName = "PyNetTestUser" try: win32net.NetUserDel(server, testName) @@ -47,7 +47,7 @@ def CreateUser(): def UserEnum(): - "Enumerates all the local users" + """Enumerates all the local users""" resume = 0 nuser = 0 while 1: @@ -67,7 +67,7 @@ def UserEnum(): def GroupEnum(): - "Enumerates all the domain groups" + """Enumerates all the domain groups""" nmembers = 0 resume = 0 while 1: @@ -92,7 +92,7 @@ def GroupEnum(): def LocalGroupEnum(): - "Enumerates all the local groups" + """Enumerates all the local groups""" resume = 0 nmembers = 0 while 1: @@ -120,7 +120,7 @@ def LocalGroupEnum(): def ServerEnum(): - "Enumerates all servers on the network" + """Enumerates all servers on the network""" resume = 0 while 1: data, total, resume = win32net.NetServerEnum( @@ -147,7 +147,7 @@ def ServerEnum(): def LocalGroup(uname=None): - "Creates a local group, adds some members, deletes them, then removes the group" + """Creates a local group, adds some members, deletes them, then removes the group""" level = 3 if uname is None: uname = win32api.GetUserName() @@ -179,7 +179,7 @@ def LocalGroup(uname=None): def GetInfo(userName=None): - "Dumps level 3 information about the current user" + """Dumps level 3 information about the current user""" if userName is None: userName = win32api.GetUserName() print("Dumping level 3 information about user") @@ -189,7 +189,7 @@ def GetInfo(userName=None): def SetInfo(userName=None): - "Attempts to change the current users comment, then set it back" + """Attempts to change the current users comment, then set it back""" if userName is None: userName = win32api.GetUserName() oldData = win32net.NetUserGetInfo(server, userName, 3) @@ -205,7 +205,7 @@ def SetInfo(userName=None): def SetComputerInfo(): - "Doesn't actually change anything, just make sure we could ;-)" + """Doesn't actually change anything, just make sure we could ;-)""" info = win32net.NetWkstaGetInfo(None, 502) # *sob* - but we can't! Why not!!! # win32net.NetWkstaSetInfo(None, 502, info) diff --git a/win32/Demos/winprocess.py b/win32/Demos/winprocess.py index d3af02f5fa..4f93f45a11 100644 --- a/win32/Demos/winprocess.py +++ b/win32/Demos/winprocess.py @@ -26,7 +26,7 @@ def logonUser(loginString): - """ + r""" Login as specified user and return handle. loginString: 'Domain\nUser\nPassword'; for local login use . or empty string as domain @@ -59,7 +59,7 @@ def __init__( xySize=None, desktop=None, ): - """ + r""" Create a Windows process. cmd: command to run login: run as user 'Domain\nUser\nPassword' diff --git a/win32/Lib/win32pdhquery.py b/win32/Lib/win32pdhquery.py index e356f89142..a3748c7bba 100644 --- a/win32/Lib/win32pdhquery.py +++ b/win32/Lib/win32pdhquery.py @@ -1,4 +1,4 @@ -""" +r""" Performance Data Helper (PDH) Query Classes Wrapper classes for end-users and high-level access to the PDH query @@ -239,7 +239,6 @@ def open(self): self.counters.append(win32pdh.AddCounter(base, path)) except win32api.error: # we passed a bad path self.counters.append(0) - pass self._base = base self.active = 1 return 0 # open succeeded diff --git a/win32/Lib/win32serviceutil.py b/win32/Lib/win32serviceutil.py index 8df954ba3d..8069f322fb 100644 --- a/win32/Lib/win32serviceutil.py +++ b/win32/Lib/win32serviceutil.py @@ -90,7 +90,7 @@ def _GetServiceShortName(longName): num = win32api.RegQueryInfoKey(hkey)[0] longName = longName.lower() # loop through number of subkeys - for x in range(0, num): + for x in range(num): # find service name, open subkey svc = win32api.RegEnumKey(hkey, x) skey = win32api.RegOpenKey(hkey, svc, 0, access) @@ -560,7 +560,7 @@ def StartService(serviceName, args=None, machine=None): def RestartService(serviceName, args=None, waitSeconds=30, machine=None): - "Stop the service, and then start it again (with some tolerance for allowing it to stop.)" + """Stop the service, and then start it again (with some tolerance for allowing it to stop.)""" try: StopService(serviceName, machine) except pywintypes.error as exc: diff --git a/win32/Lib/win32timezone.py b/win32/Lib/win32timezone.py index 6c393aaf48..1f439b266e 100644 --- a/win32/Lib/win32timezone.py +++ b/win32/Lib/win32timezone.py @@ -452,7 +452,7 @@ def __getattribute__(self, attr: str) -> Any: @classmethod def current(cls): - "Windows Platform SDK GetTimeZoneInformation" + """Windows Platform SDK GetTimeZoneInformation""" code, tzi = win32api.GetTimeZoneInformation(True) return code, cls(*tzi) @@ -728,7 +728,7 @@ def utcoffset(self, dt: None) -> None: ... @overload def utcoffset(self, dt: datetime.datetime) -> datetime.timedelta: ... def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta | None: - "Calculates the utcoffset according to the datetime.tzinfo spec" + """Calculates the utcoffset according to the datetime.tzinfo spec""" if dt is None: return None winInfo = self.getWinInfo(dt.year) @@ -782,11 +782,11 @@ def _inDaylightSavings(self, dt): return in_dst def GetDSTStartTime(self, year: int) -> datetime.datetime: - "Given a year, determines the time when daylight savings time starts" + """Given a year, determines the time when daylight savings time starts""" return self.getWinInfo(year).locate_daylight_start(year) def GetDSTEndTime(self, year: int) -> datetime.datetime: - "Given a year, determines the time when daylight savings ends." + """Given a year, determines the time when daylight savings ends.""" return self.getWinInfo(year).locate_standard_start(year) def __eq__(self, other: object) -> bool: @@ -848,7 +848,7 @@ def utc(cls) -> Self: # helper methods for accessing the timezone info from the registry @staticmethod def _get_time_zone_key(subkey=None): - "Return the registry key that stores time zone details" + """Return the registry key that stores time zone details""" key = _RegKeyDict.open(winreg.HKEY_LOCAL_MACHINE, TimeZoneInfo.tzRegKey) if subkey: key = key.subkey(subkey) @@ -856,7 +856,7 @@ def _get_time_zone_key(subkey=None): @staticmethod def _get_time_zone_key_names(): - "Returns the names of the (registry keys of the) time zones" + """Returns the names of the (registry keys of the) time zones""" return TimeZoneInfo._get_time_zone_key().subkeys() @staticmethod @@ -941,7 +941,7 @@ def _enumerate_reg_keys(key): def _enumerate_reg( key: _T, func: Callable[[_T, int], _VT] ) -> Generator[_VT, None, None]: - "Enumerates an open registry key as an iterable generator" + """Enumerates an open registry key as an iterable generator""" try: for index in count(): yield func(key, index) diff --git a/win32/scripts/h2py.py b/win32/scripts/h2py.py index 477d6cefb1..a25017f4f1 100644 --- a/win32/scripts/h2py.py +++ b/win32/scripts/h2py.py @@ -42,7 +42,7 @@ p_define = re.compile(r"^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)[\t ]+") p_macro = re.compile( - r"^[\t ]*#[\t ]*define[\t ]+" r"([a-zA-Z0-9_]+)\(([_a-zA-Z][_a-zA-Z0-9]*)\)[\t ]+" + r"^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)\(([_a-zA-Z][_a-zA-Z0-9]*)\)[\t ]+" ) p_include = re.compile(r"^[\t ]*#[\t ]*include[\t ]+<([^>\n]+)>") diff --git a/win32/scripts/pywin32_postinstall.py b/win32/scripts/pywin32_postinstall.py index 3348b8cdd8..6690cd4269 100644 --- a/win32/scripts/pywin32_postinstall.py +++ b/win32/scripts/pywin32_postinstall.py @@ -541,7 +541,7 @@ def install(lib_dir): # importing win32com.client ensures the gen_py dir created - not strictly # necessary to do now, but this makes the installation "complete" try: - import win32com.client # noqa + import win32com.client # noqa: I001, PLC0415 except ImportError: # Don't let this error sound fatal pass diff --git a/win32/test/test_security.py b/win32/test/test_security.py index 11e9780de2..cd7943d37c 100644 --- a/win32/test/test_security.py +++ b/win32/test/test_security.py @@ -80,7 +80,7 @@ def testMemory(self): sacl.AddAuditAccessAce( win32security.ACL_REVISION, win32con.GENERIC_ALL, pwr_sid, 1, 1 ) - for x in range(0, 200000): + for x in range(200000): if admin_sid is not None: sd1.SetSecurityDescriptorOwner(admin_sid, 0) sd2.SetSecurityDescriptorGroup(pwr_sid, 0)