From 3494fb0ddd84cf6bb9ebf589d83df9b89cad5bd1 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 18 May 2024 19:03:41 +0200 Subject: [PATCH 1/4] Apply ruff/flake8-implicit-str-concat rule ISC001 ISC001 Implicitly concatenated string literals on one line --- distutils/command/bdist_rpm.py | 2 +- distutils/command/register.py | 2 +- distutils/fancy_getopt.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/distutils/command/bdist_rpm.py b/distutils/command/bdist_rpm.py index 649968a5..df96507e 100644 --- a/distutils/command/bdist_rpm.py +++ b/distutils/command/bdist_rpm.py @@ -529,7 +529,7 @@ def _make_spec_file(self): # noqa: C901 # are just text that we drop in as-is. Hmmm. install_cmd = ( - '%s install -O1 --root=$RPM_BUILD_ROOT ' '--record=INSTALLED_FILES' + '%s install -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES' ) % def_setup_call script_options = [ diff --git a/distutils/command/register.py b/distutils/command/register.py index ee6c54da..1ae0e25e 100644 --- a/distutils/command/register.py +++ b/distutils/command/register.py @@ -225,7 +225,7 @@ def send_metadata(self): # noqa: C901 log.info('Server response (%s): %s', code, result) else: log.info('You will receive an email shortly.') - log.info('Follow the instructions in it to ' 'complete registration.') + log.info('Follow the instructions in it to complete registration.') elif choice == '3': data = {':action': 'password_reset'} data['email'] = '' diff --git a/distutils/fancy_getopt.py b/distutils/fancy_getopt.py index e905aede..94a63217 100644 --- a/distutils/fancy_getopt.py +++ b/distutils/fancy_getopt.py @@ -118,11 +118,11 @@ def _check_alias_dict(self, aliases, what): for alias, opt in aliases.items(): if alias not in self.option_index: raise DistutilsGetoptError( - f"invalid {what} '{alias}': " f"option '{alias}' not defined" + f"invalid {what} '{alias}': option '{alias}' not defined" ) if opt not in self.option_index: raise DistutilsGetoptError( - f"invalid {what} '{alias}': " f"aliased option '{opt}' not defined" + f"invalid {what} '{alias}': aliased option '{opt}' not defined" ) def set_aliases(self, alias): From b967476b891361467ba7cd67df58cd6087587180 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 18 May 2024 19:06:09 +0200 Subject: [PATCH 2/4] Apply ruff/flake8-implicit-str-concat rule ISC003 ISC003 Explicitly concatenated string should be implicitly concatenated --- distutils/command/bdist_dumb.py | 3 +-- distutils/command/build.py | 3 +-- distutils/command/build_ext.py | 2 +- distutils/command/install.py | 9 +++------ distutils/dist.py | 3 +-- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/distutils/command/bdist_dumb.py b/distutils/command/bdist_dumb.py index 06502d20..5966e17e 100644 --- a/distutils/command/bdist_dumb.py +++ b/distutils/command/bdist_dumb.py @@ -33,8 +33,7 @@ class bdist_dumb(Command): ( 'keep-temp', 'k', - "keep the pseudo-installation tree around after " - + "creating the distribution archive", + "keep the pseudo-installation tree around after creating the distribution archive", ), ('dist-dir=', 'd', "directory to put final built distributions in"), ('skip-build', None, "skip rebuilding everything (for testing/debugging)"), diff --git a/distutils/command/build.py b/distutils/command/build.py index d18ed503..3d896d4d 100644 --- a/distutils/command/build.py +++ b/distutils/command/build.py @@ -26,8 +26,7 @@ class build(Command): ( 'build-lib=', None, - "build directory for all distribution (defaults to either " - + "build-purelib or build-platlib", + "build directory for all distribution (defaults to either build-purelib or build-platlib", ), ('build-scripts=', None, "build directory for scripts"), ('build-temp=', 't', "temporary build directory"), diff --git a/distutils/command/build_ext.py b/distutils/command/build_ext.py index 06d949af..b80cfdf7 100644 --- a/distutils/command/build_ext.py +++ b/distutils/command/build_ext.py @@ -71,7 +71,7 @@ class build_ext(Command): 'inplace', 'i', "ignore build-lib and put compiled extensions into the source " - + "directory alongside your pure Python modules", + "directory alongside your pure Python modules", ), ( 'include-dirs=', diff --git a/distutils/command/install.py b/distutils/command/install.py index 8e920be4..e73d388d 100644 --- a/distutils/command/install.py +++ b/distutils/command/install.py @@ -193,8 +193,7 @@ class install(Command): ( 'install-platbase=', None, - "base installation directory for platform-specific files " - + "(instead of --exec-prefix or --home)", + "base installation directory for platform-specific files (instead of --exec-prefix or --home)", ), ('root=', None, "install everything relative to this alternate root directory"), # Or, explicitly set the installation scheme @@ -211,8 +210,7 @@ class install(Command): ( 'install-lib=', None, - "installation directory for all module distributions " - + "(overrides --install-purelib and --install-platlib)", + "installation directory for all module distributions (overrides --install-purelib and --install-platlib)", ), ('install-headers=', None, "installation directory for C/C++ headers"), ('install-scripts=', None, "installation directory for Python scripts"), @@ -348,8 +346,7 @@ def finalize_options(self): # noqa: C901 self.install_base or self.install_platbase ): raise DistutilsOptionError( - "must supply either prefix/exec-prefix/home or " - + "install-base/install-platbase -- not both" + "must supply either prefix/exec-prefix/home or install-base/install-platbase -- not both" ) if self.home and (self.prefix or self.exec_prefix): diff --git a/distutils/dist.py b/distutils/dist.py index 668ce7eb..1fd20d8c 100644 --- a/distutils/dist.py +++ b/distutils/dist.py @@ -652,8 +652,7 @@ def _show_help( if display_options: parser.set_option_table(self.display_options) parser.print_help( - "Information display options (just display " - + "information, ignore any commands)" + "Information display options (just display information, ignore any commands)" ) print() From 41f9d80e962dabe52ed65bb07cc7e64018bfb624 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 18 May 2024 19:06:54 +0200 Subject: [PATCH 3/4] Enable ruff/flake8-implicit-str-concat rules (ISC) --- ruff.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/ruff.toml b/ruff.toml index 70612985..e70a65b9 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,6 +1,7 @@ [lint] extend-select = [ "C901", + "ISC", "W", ] ignore = [ From 63d53880df641768c924e37f028755e2b46dabfd Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 27 Jun 2024 05:55:07 -0400 Subject: [PATCH 4/4] Combine strings for clarity. --- distutils/ccompiler.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/distutils/ccompiler.py b/distutils/ccompiler.py index ca71e18a..4585512f 100644 --- a/distutils/ccompiler.py +++ b/distutils/ccompiler.py @@ -203,8 +203,7 @@ def _check_macro_definitions(self, definitions): ): raise TypeError( f"invalid macro definition '{defn}': " - "must be tuple (string,), (string, string), or " - "(string, None)" + "must be tuple (string,), (string, string), or (string, None)" ) # -- Bookkeeping methods -------------------------------------------