Fix undefined names reported by Flake8/Ruff#2101
Conversation
Co-authored-by: kxrob <kxroberto@gmail.com>
| "Microsoft Word version 8 does not appear to be installed." | ||
| ) | ||
|
|
||
| # WordModule.Word doesn't exist in WordModule, WordModule.Words does, but CreateControl still fails |
There was a problem hiding this comment.
We could either leave this as-is if we'd like to fix it later (the calling code is still commented out, at least now tooling won't report undefined names / unbound variables).
Or delete the WordFrame class entirely (doesn't look like this part of the demo was ever run in the git history)
| if len(sys.argv) > 1: | ||
| docName = win32api.GetFullPathName(sys.argv[1]) | ||
| OleTemplate().OpenDocumentFile(None) | ||
| OleTemplate().OpenDocumentFile(docName) |
There was a problem hiding this comment.
That or remove the option to provide docName (which was unused)
Remove invalid self-referencing Remove unused and unusable tests Remove leftover casts from transpilation from c header
| raise Exception(scode=winerror.E_NOTIMPL) | ||
|
|
||
|
|
||
| def TestSmartHelper(): |
There was a problem hiding this comment.
These were commented out in the caller code (so it's unused) and contain a bunch of undefined names / unbound variables.
If you still think it's worth keeping around, I'll comment them out instead.
| @@ -1,23 +1,5 @@ | |||
| # Generated by h2py from Include\scintilla.h | |||
There was a problem hiding this comment.
I'd be curious in how to regenerate this file. It could give more insights on why there's undefined names here.
There was a problem hiding this comment.
There used to be a "h2py.py" file which came with Python - I've no idea if it still does, or if not, what happened to it.
There was a problem hiding this comment.
Removed in Python 3.9
Original issue: https://bugs.python.org/issue37704
GitHub issue: python/cpython#81885
GitHub PR: python/cpython#15000
Last version of the script before removal (no new commits between the 3.8 and 3.9 tag, other than removal): https://github.com/python/cpython/blob/3.8/Tools/scripts/h2py.py
There was a problem hiding this comment.
Alright so, long story short: These "undefined names" in files generated by h2py have always been like this (meaning broken and unusable) so removing them doesn't hurt.
They are generated like that because h2py does string manipulation on c header files, then tries to evaluate the statements. Methods can successfully be defined in python even if the symbol doesn't exists (lazy evalution), so these get added to the generated python file.
The "undefined names" are mostly C casts or other C macros.
For posterity: Some files I've been able to regenerate nearly seamlessly (other than the manual stuff added), some are even improved, others are a complete mess.
These were found by running
ruff . --select=F821 --exclude=build --exclude=Pythonwin/Scintilla --exclude=adodbapiCloses #1994 by obsoleting it. @kxrob has been made co-author of this PR in the first commit. This PR is very similar to #1994, but with the following differences:
win32comext.axdebug.util.py_wrap_remove