Skip to content

Commit

Permalink
pycln: automatic cleanup of more imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Jul 28, 2024
1 parent 377a3ef commit b0490f2
Show file tree
Hide file tree
Showing 58 changed files with 159 additions and 165 deletions.
1 change: 0 additions & 1 deletion AutoDuck/TOCToHHK.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os.path
import sys

"""
Expand Down
48 changes: 23 additions & 25 deletions Pythonwin/pywin/Demos/guidemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import sys

import __main__
import regutil
import win32api
import win32ui

demos = [ # ('Font', 'import fontdemo;fontdemo.FontDemo()'),
demos = [
# ("Font", "import fontdemo;fontdemo.FontDemo()"),
("Open GL Demo", "import openGLDemo;openGLDemo.test()"),
("Threaded GUI", "import threadedgui;threadedgui.ThreadedDemo()"),
("Tree View Demo", "import hiertest;hiertest.demoboth()"),
Expand All @@ -26,30 +26,28 @@


def demo():
try:
# seeif I can locate the demo files.
import fontdemo
except ImportError:
# else put the demos direectory on the path (if not already)
try:
instPath = regutil.GetRegistryDefaultValue(
regutil.BuildDefaultPythonKey() + "\\InstallPath"
)
except win32api.error:
print(
"The InstallPath can not be located, and the Demos directory is not on the path"
)
instPath = "."

demosDir = win32ui.FullPath(instPath + "\\Demos")
for path in sys.path:
if win32ui.FullPath(path) == demosDir:
break
else:
sys.path.append(demosDir)
import fontdemo
# try:
# # seeif I can locate the demo files.
# import fontdemo
# except ImportError:
# # else put the demos direectory on the path (if not already)
# try:
# instPath = regutil.GetRegistryDefaultValue(
# regutil.BuildDefaultPythonKey() + "\\InstallPath"
# )
# except win32api.error:
# print(
# "The InstallPath can not be located, and the Demos directory is not on the path"
# )
# instPath = "."

import sys
# demosDir = win32ui.FullPath(instPath + "\\Demos")
# for path in sys.path:
# if win32ui.FullPath(path) == demosDir:
# break
# else:
# sys.path.append(demosDir)
# import fontdemo

if "/go" in sys.argv:
for name, cmd in demos:
Expand Down
2 changes: 0 additions & 2 deletions Pythonwin/pywin/framework/bitmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import win32ui
from pywin.mfc import docview, window

from . import app

bStretch = 1


Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/editor/ModuleBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import win32con
import win32ui
from pywin.mfc import afxres
from pywin.tools import browser, hierlist
from pywin.tools import hierlist


class HierListCLBRModule(hierlist.HierListItem):
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/editor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion Pythonwin/pywin/framework/editor/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import win32con
import win32ui
from pywin.framework.editor import GetEditorOption
from pywin.mfc import docview, object

BAK_NONE = 0
BAK_DOT_BAK = 1
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pywin.framework.app
import pywin.scintilla.control
import pywin.scintilla.formatter
import pywin.scintilla.IDLEenvironment
import pywin.scintilla.IDLEenvironment # nopycln: import # Injects fast_readline into the IDLE auto-indent extension
import win32api
import win32clipboard
import win32con
Expand Down
8 changes: 7 additions & 1 deletion Pythonwin/pywin/framework/intpydde.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@

import win32api
import win32ui
from dde import *
from dde import ( # nopycln: import # Re-exported for intpyapp.py
CBF_FAIL_SELFCONNECTIONS as CBF_FAIL_SELFCONNECTIONS, # noqa: PLC0414
CreateConversation as CreateConversation, # noqa: PLC0414
CreateServer,
CreateServerSystemTopic,
error as error, # noqa: PLC0414
)
from pywin.mfc import object


Expand Down
2 changes: 0 additions & 2 deletions Pythonwin/pywin/framework/toolmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import win32con
import win32ui

from . import app

tools = {}
idPos = 100

Expand Down
4 changes: 3 additions & 1 deletion Pythonwin/pywin/scintilla/bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import win32con
import win32ui

from . import IDLEenvironment, keycodes
from . import ( # nopycln: import # Injects fast_readline into the IDLE auto-indent extension
IDLEenvironment,
)

HANDLER_ARGS_GUESS = 0
HANDLER_ARGS_NATIVE = 1
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/scintilla/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pywin.mfc import afxres, docview

from . import (
IDLEenvironment, # IDLE emulation.
IDLEenvironment, # nopycln: import # Injects fast_readline into the IDLE auto-indent extension
bindings,
control,
scintillacon,
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/test/test_pywin.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def test_ia(self):
def test_docedit(self):
import tempfile

import pywin.scintilla.IDLEenvironment
import pywin.scintilla.IDLEenvironment # nopycln: import # Injects fast_readline into the IDLE auto-indent extension

##doc = pywin.framework.editor.editorTemplate.OpenDocumentFile(None)
def t_print(*args):
Expand Down
1 change: 1 addition & 0 deletions adodbapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# nopycln: file # undecidable cases due to explicit re-exports https://github.com/hadialqattan/pycln/issues/205
"""adodbapi - A python DB API 2.0 (PEP 249) interface to Microsoft ADO
Copyright (C) 2002 Henrik Ekelund, version 2.1 by Vernon Cole
Expand Down
1 change: 0 additions & 1 deletion adodbapi/test/adodbapitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import adodbapitestconfig as config # run the configuration module. # will set sys.path to find correct version of adodbapi
import tryconnection # in our code below, all our switches are from config.whatever
import win32com.client

import adodbapi
import adodbapi.apibase as api
Expand Down
3 changes: 0 additions & 3 deletions com/win32com/client/combrowse.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ def CalculateIsExpandable(self):
rc = 0
return rc

pass


class HLI_IEnumMoniker(HLI_Enum):
def GetSubList(self):
Expand Down Expand Up @@ -595,7 +593,6 @@ def GetSubList(self):


def main(modal=True, mdi=False):
from pywin.tools import hierlist

root = HLIRoot("COM Browser")
if mdi and "pywin.framework.app" in sys.modules:
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/client/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import pythoncom
from win32com.client import Dispatch, _get_good_object_
from win32com.client import _get_good_object_

PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]

Expand Down
2 changes: 1 addition & 1 deletion com/win32com/demos/excelAddin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

import pythoncom
from win32com import universal
from win32com.client import Dispatch, DispatchWithEvents, constants, gencache
from win32com.client import DispatchWithEvents, constants, gencache

# Support for COM objects we use.
gencache.EnsureModule(
Expand Down
3 changes: 0 additions & 3 deletions com/win32com/demos/iebutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import win32api
import win32com
import win32com.server.register
from win32com import universal
from win32com.client import Dispatch, DispatchWithEvents, constants, gencache, getevents

# This demo uses 'print' - use win32traceutil to see it if we have no
# console.
Expand All @@ -40,7 +38,6 @@
except win32api.error:
import win32traceutil

import array

from win32com.axcontrol import axcontrol

Expand Down
2 changes: 1 addition & 1 deletion com/win32com/server/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def _HandleException_(self):


try:
import win32trace
import win32trace # nopycln: import # Check for win32traceutil w/o importing it

DefaultDebugDispatcher: type[DispatcherTrace] = DispatcherWin32trace
except ImportError: # no win32trace module - just use a print based one.
Expand Down
9 changes: 6 additions & 3 deletions com/win32com/server/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
problem, rather than a COM error.
"""

__author__ = "Greg Stein and Mark Hammond"

import sys
import types

Expand All @@ -92,6 +90,8 @@

from .exception import COMException

__author__ = "Greg Stein and Mark Hammond"

S_OK = 0

# Few more globals to speed things.
Expand Down Expand Up @@ -812,6 +812,9 @@ def _import_module(mname):
# These have been moved to a new source file, but some code may
# still reference them here. These will end up being removed.
try:
from .dispatcher import DispatcherTrace, DispatcherWin32trace
from .dispatcher import ( # nopycln: import
DispatcherTrace as DispatcherTrace, # noqa: PLC0414 # Explicit re-export of unused symbol
DispatcherWin32trace as DispatcherWin32trace, # noqa: PLC0414 # Explicit re-export of unused symbol
)
except ImportError: # Quite likely a frozen executable that doesn't need dispatchers
pass
1 change: 0 additions & 1 deletion com/win32com/servers/test_pycomtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import winerror

# Ensure the vtables in the tlb are known.
from win32com import universal
from win32com.client import constants, gencache
from win32com.server.exception import COMException
from win32com.server.util import wrap
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/test/testADOEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time

import pythoncom
from win32com.client import Dispatch, DispatchWithEvents, constants
from win32com.client import DispatchWithEvents, constants

finished = 0 # Flag for the wait loop from (3) to test

Expand Down
3 changes: 1 addition & 2 deletions com/win32com/test/testExchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os

import pythoncom
from win32com.client import constants, gencache
from win32com.client import gencache

ammodule = None # was the generated module!

Expand Down Expand Up @@ -94,7 +94,6 @@ def TestUser(session):


def test():
import win32com.client

oldcwd = os.getcwd()
try:
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/test/testMSOffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def TestAll():
traceback.print_exc()

try:
import xl5en32
import xl5en32 # nopycln: import # Test import. TODO: Is testing Excel 95 still relevant ?

mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}", 9, 1, 0)
xl = win32com.client.Dispatch("Excel.Application.5")
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/test/testMSOfficeEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import types

import pythoncom
from win32com.client import Dispatch, DispatchWithEvents
from win32com.client import DispatchWithEvents

stopEvent = threading.Event()

Expand Down
3 changes: 1 addition & 2 deletions com/win32com/test/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import gc
import logging
import os
import sys
Expand All @@ -13,7 +12,7 @@
import win32com
import winerror
from pythoncom import _GetGatewayCount, _GetInterfaceCount
from pywin32_testutil import LeakTestCase, TestLoader, TestResult, TestRunner
from pywin32_testutil import LeakTestCase


def CheckClean():
Expand Down
25 changes: 1 addition & 24 deletions com/win32comext/authorization/demos/EditSecurity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os

import ntsecuritycon
import pythoncom
import win32api
import win32com.server.policy
Expand All @@ -12,43 +11,21 @@
FILE_GENERIC_EXECUTE,
FILE_GENERIC_READ,
FILE_GENERIC_WRITE,
FILE_READ_ATTRIBUTES,
FILE_READ_DATA,
FILE_READ_EA,
FILE_WRITE_ATTRIBUTES,
FILE_WRITE_DATA,
FILE_WRITE_EA,
PSPCB_SI_INITDIALOG,
READ_CONTROL,
SI_ACCESS_CONTAINER,
SI_ACCESS_GENERAL,
SI_ACCESS_PROPERTY,
SI_ACCESS_SPECIFIC,
SI_ADVANCED,
SI_CONTAINER,
SI_EDIT_ALL,
SI_EDIT_AUDITS,
SI_EDIT_PROPERTIES,
SI_PAGE_ADVPERM,
SI_PAGE_AUDIT,
SI_PAGE_OWNER,
SI_PAGE_PERM,
SI_PAGE_TITLE,
SI_RESET,
STANDARD_RIGHTS_EXECUTE,
STANDARD_RIGHTS_READ,
STANDARD_RIGHTS_WRITE,
SYNCHRONIZE,
WRITE_DAC,
WRITE_OWNER,
)
from pythoncom import IID_NULL
from win32com.authorization import authorization
from win32com.shell.shellcon import ( # # Msg parameter to PropertySheetPageCallback
PSPCB_CREATE,
PSPCB_RELEASE,
)
from win32security import CONTAINER_INHERIT_ACE, INHERIT_ONLY_ACE, OBJECT_INHERIT_ACE
from win32security import CONTAINER_INHERIT_ACE, OBJECT_INHERIT_ACE


class SecurityInformation(win32com.server.policy.DesignatedWrapPolicy):
Expand Down
Loading

0 comments on commit b0490f2

Please sign in to comment.