-
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
pycln: cleanup of more imports #2342
Conversation
@@ -100,4 +100,4 @@ def SetEditorFontOption(option, newValue): | |||
SetEditorOption(option, str(newValue)) | |||
|
|||
|
|||
from pywin.framework.editor.color.coloreditor import editorTemplate | |||
import pywin.framework.editor.color.coloreditor # nopycln: import # Adds doc template |
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.
Assuming this side-effect is wanted here:
pywin32/Pythonwin/pywin/framework/editor/color/coloreditor.py
Lines 639 to 646 in 377a3ef
# For debugging purposes, when this module may be reloaded many times. | |
try: | |
win32ui.GetApp().RemoveDocTemplate(editorTemplate) # type: ignore[has-type, used-before-def] | |
except NameError: | |
pass | |
editorTemplate = SyntEditTemplate() | |
win32ui.GetApp().AddDocTemplate(editorTemplate) |
from . import ( # nopycln: import # Injects fast_readline into the IDLE auto-indent extension | ||
IDLEenvironment, | ||
) |
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.
If injecting in the extension isn't needed when IDLEenvironment
isn't used directly (it's imported in a couple other places), then this can be removed.
pycln.toml
Outdated
"pythoncom", | ||
"pywintypes", | ||
"win32api", | ||
"win32clipboard", | ||
"win32com", | ||
"win32cryptcon", | ||
"win32event", | ||
"win32file", | ||
"win32gui_struct", | ||
"win32gui", | ||
"win32inet", | ||
"win32inetcon", | ||
"win32pipe", | ||
"win32ras", | ||
"win32ui", | ||
"win32process", | ||
"win32security", | ||
"win32uiole", |
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.
Do you know if any of these produce side-effects in a way one might want to import the module w/o using any of its symbols?
"pythoncom",
"pywintypes",
"win32api",
"win32file",
"win32gui",
"win32process",
"win32security",
"win32uiole",
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.
pywintypes might for the loader, but I don't think the rest do.
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.
Noted. I'd like to merge this PR as-is w/o tackling additional changes in Python files, so I added it to the comment.
c88531e
to
b0490f2
Compare
pycln.toml
Outdated
"pythoncom", | ||
"pywintypes", | ||
"win32api", | ||
"win32clipboard", | ||
"win32com", | ||
"win32cryptcon", | ||
"win32event", | ||
"win32file", | ||
"win32gui_struct", | ||
"win32gui", | ||
"win32inet", | ||
"win32inetcon", | ||
"win32pipe", | ||
"win32ras", | ||
"win32ui", | ||
"win32process", | ||
"win32security", | ||
"win32uiole", |
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.
pywintypes might for the loader, but I don't think the rest do.
See per-file comments for more details.
Some expanded star imports with lots of entries might be better as
import x
instead offrom x import a, b, c, ...