-
Notifications
You must be signed in to change notification settings - Fork 810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
@@ -142,11 +150,12 @@ def Demo(): | |||
docName = None | |||
if len(sys.argv) > 1: | |||
docName = win32api.GetFullPathName(sys.argv[1]) | |||
OleTemplate().OpenDocumentFile(None) | |||
OleTemplate().OpenDocumentFile(docName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
com/win32comext/axdebug/Test/host.py
Outdated
|
||
def NotifyChanged(): | ||
trace("NotifyChanged") | ||
raise Exception(scode=winerror.E_NOTIMPL) | ||
|
||
|
||
def TestSmartHelper(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
These were found by running
ruff . --select=F821 --exclude=build --exclude=Pythonwin/Scintilla --exclude=adodbapi
Closes #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