-
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
Changes from 5 commits
e9625d4
96e6b04
57996d7
3423708
e9d306c
920708c
cd3026c
130c0da
623fb6a
4a364be
2db7f95
b72ba9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,6 @@ | |
from pywin.mfc import activex, docview, object, window | ||
from win32com.client import gencache | ||
|
||
# WordModule = gencache.EnsureModule('{00020905-0000-0000-C000-000000000046}', 1033, 8, 0) | ||
# if WordModule is None: | ||
# raise ImportError, "Microsoft Word version 8 does not appear to be installed." | ||
|
||
|
||
class OleClientItem(object.CmdTarget): | ||
def __init__(self, doc): | ||
|
@@ -123,6 +119,18 @@ def __init__(self, doc=None): | |
# Dont call base class doc/view version... | ||
|
||
def Create(self, title, rect=None, parent=None): | ||
WordModule = gencache.EnsureModule( | ||
"{00020905-0000-0000-C000-000000000046}", 1033, 8, 0 | ||
) | ||
if WordModule is None: | ||
raise ImportError( | ||
"Microsoft Word version 8 does not appear to be installed." | ||
) | ||
|
||
# WordModule.Word doesn't exist in WordModule, WordModule.Words does, but CreateControl still fails | ||
class MyWordControl(activex.Control, WordModule.Word): | ||
... | ||
|
||
style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_OVERLAPPEDWINDOW | ||
self._obj_.CreateWindow(None, title, style, rect, parent) | ||
|
||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. That or remove the option to provide |
||
|
||
# ActiveX not currently working | ||
# f = WordFrame(docName) | ||
# f.Create("Microsoft Office") | ||
|
||
# f = WordFrame(docName) | ||
# f.Create("Microsoft Office") | ||
|
||
if __name__ == "__main__": | ||
Demo() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
import re | ||
import sys | ||
import time | ||
from functools import reduce | ||
|
||
import win32api | ||
import win32con | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,5 @@ | ||
# Generated by h2py from Include\scintilla.h | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Removed in Python 3.9 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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. |
||
|
||
|
||
# Included from BaseTsd.h | ||
def HandleToUlong(h): | ||
return HandleToULong(h) | ||
|
||
|
||
def UlongToHandle(ul): | ||
return ULongToHandle(ul) | ||
|
||
|
||
def UlongToPtr(ul): | ||
return ULongToPtr(ul) | ||
|
||
|
||
def UintToPtr(ui): | ||
return UIntToPtr(ui) | ||
|
||
|
||
INVALID_POSITION = -1 | ||
SCI_START = 2000 | ||
SCI_OPTIONAL_START = 3000 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ class Dummy2: | |
] | ||
|
||
|
||
class DeletgatedDummy: | ||
class DelegatedDummy: | ||
_public_methods_ = [] | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
# | ||
|
||
import traceback | ||
from collections.abc import Callable | ||
|
||
import pythoncom | ||
import win32com.client | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import string | ||
import sys | ||
from collections.abc import Callable | ||
|
||
import pythoncom | ||
import win32api | ||
|
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)