From c624039a249c2f0e80f711ad8dadf3aa9cd20319 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 4 Oct 2024 19:08:11 -0400 Subject: [PATCH 1/3] Fixed unbound global variables in `pywin.dialogs.ideoptions.OptionsPropPage`'s `OnFormat*` methods --- CHANGES.txt | 2 ++ Pythonwin/pywin/dialogs/ideoptions.py | 17 +++++++---------- adodbapi/process_connect_string.py | 2 ++ pyrightconfig.json | 3 +-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index fd800ca290..f451c47bab 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,8 @@ https://mhammond.github.io/pywin32_installers.html. Coming in build 308, as yet unreleased -------------------------------------- +* Fixed unbound global variables in `pywin.dialogs.ideoptions.OptionsPropPage`'s `OnFormat*` methods (#2283, @Avasam) + Build 307, released 2024-10-04 ------------------------------ ### Release process changes diff --git a/Pythonwin/pywin/dialogs/ideoptions.py b/Pythonwin/pywin/dialogs/ideoptions.py index cee8ee8931..da7c4c5779 100644 --- a/Pythonwin/pywin/dialogs/ideoptions.py +++ b/Pythonwin/pywin/dialogs/ideoptions.py @@ -114,26 +114,23 @@ def ChangeFormat(self, fmtAttribute, fmt): def OnFormatTitle(self, command, code): fmt = self.GetFormat(interact.formatTitle) if fmt: - formatTitle = fmt + interact.formatTitle = fmt interact.SaveFontPreferences() def OnFormatInput(self, command, code): - global formatInput - fmt = self.GetFormat(formatInput) + fmt = self.GetFormat(interact.formatInput) if fmt: - formatInput = fmt + interact.formatInput = fmt interact.SaveFontPreferences() def OnFormatOutput(self, command, code): - global formatOutput - fmt = self.GetFormat(formatOutput) + fmt = self.GetFormat(interact.formatOutput) if fmt: - formatOutput = fmt + interact.formatOutput = fmt interact.SaveFontPreferences() def OnFormatError(self, command, code): - global formatOutputError - fmt = self.GetFormat(formatOutputError) + fmt = self.GetFormat(interact.formatOutputError) if fmt: - formatOutputError = fmt + interact.formatOutputError = fmt interact.SaveFontPreferences() diff --git a/adodbapi/process_connect_string.py b/adodbapi/process_connect_string.py index d8b29f280c..d71ffd2ffb 100644 --- a/adodbapi/process_connect_string.py +++ b/adodbapi/process_connect_string.py @@ -45,6 +45,8 @@ def macro_call(macro_name, args, kwargs): return new_key, platform.node() elif macro_name == "getenv": # expand the server's environment variable args[1] + import os + try: dflt = args[2] # if not found, default from args[2] except IndexError: # or blank diff --git a/pyrightconfig.json b/pyrightconfig.json index bc3c26fbc0..2570cce2c8 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -37,8 +37,7 @@ "reportOptionalIterable": "warning", "reportOptionalMemberAccess": "warning", "reportOptionalSubscript": "warning", - // TODO: Leave Unbound/Undefined to their own PR(s) - "reportUnboundVariable": "warning", + // TODO: Leave Undefined to its own PR(s) "reportUndefinedVariable": "warning", // Too many dynamically generated modules. This will require type stubs to properly fix. "reportMissingImports": "warning", From af956d258d6288e41ba097a8b5ddac6fb2c24694 Mon Sep 17 00:00:00 2001 From: Avasam Date: Wed, 23 Oct 2024 17:53:01 -0400 Subject: [PATCH 2/3] Update pyrightconfig.json --- pyrightconfig.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index e61dab12a2..db5c3e6c3d 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -39,8 +39,6 @@ "reportOptionalSubscript": "warning", // Needs fixes in types-pywin32 and requires Python 3.8 to annotate ambiguous global variables "reportUnnecessaryComparison": "warning", - // TODO: Leave Undefined to its own PR(s) - "reportUndefinedVariable": "warning", // Too many dynamically generated modules. This will require type stubs to properly fix. "reportMissingImports": "warning", // IDEM, but happens when pywin32 is not in site-packages but module is found from typeshed. From 21c625ca93e6aac0712a9dcb57d7699c4508d219 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 11 Nov 2024 13:17:14 -0500 Subject: [PATCH 3/3] Fix unrelated warnings --- pyrightconfig.json | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index db5c3e6c3d..c35e4a565b 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -6,6 +6,7 @@ "enableTypeIgnoreComments": true, // Exclude from scanning when running pyright "exclude": [ + ".git/", "build/", // Vendored "Pythonwin/Scintilla/", diff --git a/setup.py b/setup.py index e72edf0ade..fcd1d6381b 100644 --- a/setup.py +++ b/setup.py @@ -926,7 +926,7 @@ class my_compiler(MSVCCompiler): # worse! This can probably go away once we kill the VS project files # though, as we can just specify the lowercase name in the module def. _cpp_extensions = MSVCCompiler._cpp_extensions + [".CPP"] - src_extensions = MSVCCompiler.src_extensions + [".CPP"] + src_extensions = MSVCCompiler.src_extensions + [".CPP"] # type: ignore[operator] # TODO: Fix in typeshed def link( self,