From a8966115adc4252c8bae078b1e356ccd3b1077f2 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 10 Sep 2024 12:42:35 +0200 Subject: [PATCH] Manually remove more .format() calls --- docs/userguide/extension.rst | 2 +- pkg_resources/__init__.py | 8 ++------ setuptools/msvc.py | 14 +++++++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/docs/userguide/extension.rst b/docs/userguide/extension.rst index e1e37b5db1..ef5e33f3a8 100644 --- a/docs/userguide/extension.rst +++ b/docs/userguide/extension.rst @@ -122,7 +122,7 @@ a non-``None`` value. Here's an example validation function:: """Verify that value is True, False, 0, or 1""" if bool(value) != value: raise SetupError( - "%r must be a boolean value (got %r)" % (attr,value) + f"{attr!r} must be a boolean value (got {value!r}" ) Your function should accept three arguments: the ``Distribution`` object, diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index eeea085e39..8b88a6e379 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -456,12 +456,8 @@ def get_build_platform(): if sys.platform == "darwin" and not plat.startswith('macosx-'): try: version = _macos_vers() - machine = os.uname()[4].replace(" ", "_") - return "macosx-%d.%d-%s" % ( - int(version[0]), - int(version[1]), - _macos_arch(machine), - ) + machine = _macos_arch(os.uname()[4].replace(" ", "_")) + return f"macosx-{version[0]}.{version[1]}-{machine}" except ValueError: # if someone is running a non-Mac darwin system, this will fall # through to the default implementation diff --git a/setuptools/msvc.py b/setuptools/msvc.py index 185c5e2897..5ceca6a09e 100644 --- a/setuptools/msvc.py +++ b/setuptools/msvc.py @@ -664,8 +664,8 @@ def WindowsSDKExecutablePath(self): else: netfxver = 40 hidex86 = True if self.vs_ver <= 12.0 else False - arch = self.pi.current_dir(x64=True, hidex86=hidex86) - fx = 'WinSDK-NetFx%dTools%s' % (netfxver, arch.replace('\\', '-')) + arch = self.pi.current_dir(x64=True, hidex86=hidex86).replace('\\', '-') + fx = f'WinSDK-NetFx{netfxver}Tools{arch}' # list all possibles registry paths regpaths = [] @@ -836,8 +836,8 @@ def _find_dot_net_versions(self, bits): versions """ # Find actual .NET version in registry - reg_ver = self.ri.lookup(self.ri.vc, 'frameworkver%d' % bits) - dot_net_dir = getattr(self, 'FrameworkDir%d' % bits) + reg_ver = self.ri.lookup(self.ri.vc, f'frameworkver{bits}') + dot_net_dir = getattr(self, f'FrameworkDir{bits}') ver = reg_ver or self._use_last_dir_name(dot_net_dir, 'v') or '' # Set .NET versions for specified MSVC++ version @@ -1393,7 +1393,7 @@ def VCRuntimeRedist(self) -> str | None: Returns the first suitable path found or None. """ - vcruntime = 'vcruntime%d0.dll' % self.vc_ver + vcruntime = f'vcruntime{self.vc_ver}0.dll' arch_subdir = self.pi.target_dir(x64=True).strip('\\') # Installation prefixes candidates @@ -1409,9 +1409,9 @@ def VCRuntimeRedist(self) -> str | None: # CRT directory crt_dirs = ( - 'Microsoft.VC%d.CRT' % (self.vc_ver * 10), + f'Microsoft.VC{self.vc_ver * 10}.CRT', # Sometime store in directory with VS version instead of VC - 'Microsoft.VC%d.CRT' % (int(self.vs_ver) * 10), + f'Microsoft.VC{int(self.vs_ver) * 10}.CRT', ) # vcruntime path