Skip to content

Commit

Permalink
PEP 616, string methods to remove prefixes and suffixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Oct 19, 2024
1 parent 44e60d2 commit bb2db97
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Pythonwin/pywin/framework/intpyapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import sys
import traceback
from collections.abc import Iterable, Sequence

import __main__
import commctrl
Expand Down Expand Up @@ -268,7 +269,7 @@ def Activate(self):
if frame.GetWindowPlacement()[1] == win32con.SW_SHOWMINIMIZED:
frame.ShowWindow(win32con.SW_RESTORE)

def ProcessArgs(self, args, dde=None):
def ProcessArgs(self, args: Sequence[str], dde=None):
# If we are going to talk to a remote app via DDE, then
# activate it!
if (
Expand All @@ -290,7 +291,7 @@ def ProcessArgs(self, args, dde=None):
).lower()
i -= 1 # arg is /edit's parameter
par = i < len(args) and args[i] or "MISSING"
if argType in ("/nodde", "/new", "-nodde", "-new"):
if argType in ("/nodde", "/new"):
# Already handled
pass
elif argType.startswith("/goto:"):
Expand Down
1 change: 1 addition & 0 deletions com/win32com/client/gencache.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def _LoadDicts():
arc_path = loader.archive
dicts_path = os.path.join(win32com.__gen_path__, "dicts.dat")
if dicts_path.startswith(arc_path):
# Remove the leading slash as well
dicts_path = dicts_path[len(arc_path) + 1 :]
else:
# Hm. See below.
Expand Down
5 changes: 2 additions & 3 deletions isapi/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ def _PatchParamsModule(params, dll_name, file_must_exist=True):
sm.Module = dll_name


def GetLoaderModuleName(mod_name, check_module=None):
def GetLoaderModuleName(mod_name: str, check_module=None):
# find the name of the DLL hosting us.
# By default, this is "_{module_base_name}.dll"
if hasattr(sys, "frozen"):
Expand All @@ -635,8 +635,7 @@ def GetLoaderModuleName(mod_name, check_module=None):
base, ext = os.path.splitext(mod_name)
path, base = os.path.split(base)
# handle the common case of 'foo.exe'/'foow.exe'
if base.endswith("w"):
base = base[:-1]
base.removesuffix("w")
# For py2exe, we have '_foo.dll' as the standard pyisapi loader - but
# 'foo.dll' is what we use (it just delegates).
# So no leading '_' on the installed name.
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2024,9 +2024,7 @@ def convert_data_files(files: Iterable[str]):
raise RuntimeError("No file '%s'" % file)
files_use = (file,)
for fname in files_use:
path_use = os.path.dirname(fname)
if path_use.startswith("com\\"):
path_use = path_use[4:]
path_use = os.path.dirname(fname).removeprefix("com\\")
ret.append((path_use, (fname,)))
return ret

Expand Down
9 changes: 5 additions & 4 deletions win32/scripts/VersionStamp/bulkstamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import fnmatch
import os
import sys
from collections.abc import Mapping
from collections.abc import Iterable, Mapping
from optparse import Values

try:
Expand All @@ -51,7 +51,9 @@
]


def walk(vars: Mapping[str, str], debug, descriptions, dirname, names) -> int:
def walk(
vars: Mapping[str, str], debug, descriptions, dirname, names: Iterable[str]
) -> int:
"""Returns the number of stamped files."""
numStamped = 0
for name in names:
Expand All @@ -60,8 +62,7 @@ def walk(vars: Mapping[str, str], debug, descriptions, dirname, names) -> int:
# Handle the "_d" thing.
pathname = os.path.join(dirname, name)
base, ext = os.path.splitext(name)
if base.endswith("_d"):
name = base[:-2] + ext
name = base.removesuffix("_d") + ext
is_dll = ext.lower() != ".exe"
if os.path.normcase(name) in descriptions:
description = descriptions[os.path.normcase(name)]
Expand Down

0 comments on commit bb2db97

Please sign in to comment.