diff --git a/ruff.toml b/ruff.toml index 51d7cf698a..48db0af1e7 100644 --- a/ruff.toml +++ b/ruff.toml @@ -8,4 +8,4 @@ ignore = ["D100","D101","D102","D103","D105","N806","E501"] exclude = ["wagtail/project_template/*","node_modules","venv",".venv","migrations"] line-length = 88 -select = ["E", "F", "I"] +select = ["E", "F", "I", "T20"] diff --git a/scripts/check-translation-strings.py b/scripts/check-translation-strings.py index aefbb84a21..8fd9613a8f 100644 --- a/scripts/check-translation-strings.py +++ b/scripts/check-translation-strings.py @@ -14,13 +14,13 @@ for path in Path(__file__).parent.resolve().parent.rglob("LC_MESSAGES/*.po"): expected_placeholders = set(placeholder_regexp.findall(entry.msgid)) actual_placeholders = set(placeholder_regexp.findall(entry.msgstr)) if expected_placeholders != actual_placeholders: - print("Invalid string at %s line %d:" % (path, entry.linenum)) # noqa - print( # noqa + print("Invalid string at %s line %d:" % (path, entry.linenum)) # noqa: T201 + print( # noqa: T201 "\toriginal string %r has placeholders: %r" % (entry.msgid, expected_placeholders) - ) # noqa - print( # noqa + ) + print( # noqa: T201 "\ttranslated string %r has placeholders: %r" % (entry.msgstr, actual_placeholders) - ) # noqa - print() # noqa + ) + print() # noqa: T201 diff --git a/scripts/get-translator-credits.py b/scripts/get-translator-credits.py index cc8d28b57e..99d871003e 100644 --- a/scripts/get-translator-credits.py +++ b/scripts/get-translator-credits.py @@ -60,8 +60,8 @@ language_names = [ language_names.sort() for (language_name, locale) in language_names: - print(("%s - %s" % (language_name, locale))) # noqa - print("-----") # noqa + print(("%s - %s" % (language_name, locale))) # noqa: T201 + print("-----") # noqa: T201 for author in sorted(authors_by_locale[locale]): - print(author.replace("@", ".")) # noqa - print("") # noqa + print(author.replace("@", ".")) # noqa: T201 + print("") # noqa: T201 diff --git a/scripts/nightly/get_version.py b/scripts/nightly/get_version.py index 5ece65113d..973970ebff 100644 --- a/scripts/nightly/get_version.py +++ b/scripts/nightly/get_version.py @@ -22,7 +22,7 @@ __semver__ = get_semver_version(VERSION) """ -print( # noqa +print( # noqa: T201 INIT_TEMPLATE.format( major=VERSION[0], minor=VERSION[1], diff --git a/scripts/nightly/upload.py b/scripts/nightly/upload.py index 846ca3a847..8b0bebc809 100644 --- a/scripts/nightly/upload.py +++ b/scripts/nightly/upload.py @@ -9,10 +9,10 @@ dist_folder = pathlib.Path.cwd() / "dist" try: f = next(dist_folder.glob("*.whl")) except StopIteration: - print("No .whl files found in ./dist!") # noqa + print("No .whl files found in ./dist!") # noqa: T201 sys.exit() -print("Uploading", f.name) # noqa +print("Uploading", f.name) # noqa: T201 s3 = boto3.client("s3") s3.upload_file( str(f), @@ -21,7 +21,7 @@ s3.upload_file( ExtraArgs={"ACL": "public-read"}, ) -print("Updating latest.json") # noqa +print("Updating latest.json") # noqa: T201 boto3.resource("s3").Object("releases.wagtail.io", "nightly/latest.json").put( ACL="public-read", diff --git a/wagtail/bin/wagtail.py b/wagtail/bin/wagtail.py index 5ac406d92d..ec0b59c5da 100644 --- a/wagtail/bin/wagtail.py +++ b/wagtail/bin/wagtail.py @@ -79,10 +79,10 @@ class CreateProject(Command): "name. Please try another name." % project_name ) - print( # noqa + print( # noqa: T201 "Creating a Wagtail project called %(project_name)s" % {"project_name": project_name} - ) # noqa + ) # Create the project from the Wagtail template using startapp @@ -108,10 +108,10 @@ class CreateProject(Command): utility = ManagementUtility(utility_args) utility.execute() - print( # noqa + print( # noqa: T201 "Success! %(project_name)s has been created" % {"project_name": project_name} - ) # noqa + ) class UpdateModulePaths(Command): @@ -239,16 +239,16 @@ class UpdateModulePaths(Command): else: # actually update change_count = self._rewrite_file(path) if change_count: - print( # noqa + print( # noqa: T201 "%s - %d change%s" % (relative_path, change_count, pluralize(change_count)) - ) # NOQA + ) if change_count: changed_file_count += 1 if diff or list_files: - print( # noqa + print( # noqa: T201 "\nChecked %d .py file%s, %d file%s to update." % ( checked_file_count, @@ -256,9 +256,9 @@ class UpdateModulePaths(Command): changed_file_count, pluralize(changed_file_count), ) - ) # NOQA + ) else: - print( # noqa + print( # noqa: T201 "\nChecked %d .py file%s, %d file%s updated." % ( checked_file_count, @@ -266,7 +266,7 @@ class UpdateModulePaths(Command): changed_file_count, pluralize(changed_file_count), ) - ) # NOQA + ) def _rewrite_line(self, line): for pattern, repl in self.REPLACEMENTS: @@ -381,7 +381,7 @@ class Version(Command): version = wagtail.get_version(wagtail.VERSION) - print("You are using Wagtail %(version)s" % {"version": version}) # noqa + print("You are using Wagtail %(version)s" % {"version": version}) # noqa: T201 COMMANDS = { @@ -396,17 +396,17 @@ def prog_name(): def help_index(): - print( # noqa + print( # noqa: T201 "Type '%s help ' for help on a specific subcommand.\n" % prog_name() - ) # NOQA - print("Available subcommands:\n") # NOQA + ) + print("Available subcommands:\n") # NOQA: T201 for name, cmd in sorted(COMMANDS.items()): - print(" %s%s" % (name.ljust(20), cmd.description)) # NOQA + print(" %s%s" % (name.ljust(20), cmd.description)) # NOQA: T201 def unknown_command(command): - print("Unknown command: '%s'" % command) # NOQA - print("Type '%s help' for usage." % prog_name()) # NOQA + print("Unknown command: '%s'" % command) # NOQA: T201 + print("Type '%s help' for usage." % prog_name()) # NOQA: T201 sys.exit(1) diff --git a/wagtail/test/benchmark.py b/wagtail/test/benchmark.py index ddbeb45e7e..f1093eda05 100644 --- a/wagtail/test/benchmark.py +++ b/wagtail/test/benchmark.py @@ -27,19 +27,19 @@ class Benchmark: ) ) - print( # noqa + print( # noqa: T201 "time min:", min(timings), "max:", max(timings), "avg:", sum(timings) / len(timings), - ) # NOQA - print( # noqa + ) + print( # noqa: T201 "memory min:", min(memory_usage), "max:", max(memory_usage), "avg:", sum(memory_usage) / len(memory_usage), - ) # NOQA + ) diff --git a/wagtail/test/settings.py b/wagtail/test/settings.py index db375c9983..b9a2ba2d02 100644 --- a/wagtail/test/settings.py +++ b/wagtail/test/settings.py @@ -62,7 +62,7 @@ if os.environ.get("STATICFILES_STORAGE", "") == "manifest": USE_TZ = not os.environ.get("DISABLE_TIMEZONE") if not USE_TZ: - print("Timezone support disabled") # noqa + print("Timezone support disabled") # noqa: T201 LANGUAGE_CODE = "en" @@ -186,7 +186,7 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" if os.environ.get("USE_EMAIL_USER_MODEL"): INSTALLED_APPS.append("wagtail.test.emailuser") AUTH_USER_MODEL = "emailuser.EmailUser" - print("EmailUser (no username) user model active") # noqa + print("EmailUser (no username) user model active") # noqa: T201 else: INSTALLED_APPS.append("wagtail.test.customuser") AUTH_USER_MODEL = "customuser.CustomUser" diff --git a/wagtail/utils/setup.py b/wagtail/utils/setup.py index f3f4ae9a8e..64a243fc0d 100644 --- a/wagtail/utils/setup.py +++ b/wagtail/utils/setup.py @@ -15,14 +15,14 @@ class assets_mixin: try: subprocess.check_call(["npm", "run", "build"]) except (OSError, subprocess.CalledProcessError) as e: - print("Error compiling assets: " + str(e)) # noqa + print("Error compiling assets: " + str(e)) # noqa: T201 raise SystemExit(1) def publish_assets(self): try: subprocess.check_call(["npm", "publish", "client"]) except (OSError, subprocess.CalledProcessError) as e: - print("Error publishing front-end assets: " + str(e)) # noqa + print("Error publishing front-end assets: " + str(e)) # noqa: T201 raise SystemExit(1) def bump_client_version(self): @@ -35,7 +35,7 @@ class assets_mixin: try: package = json.loads(input_file.read().decode("utf-8")) except (ValueError) as e: - print("Unable to read " + path + " " + e) # noqa + print("Unable to read " + path + " " + e) # noqa: T201 raise SystemExit(1) package["version"] = __semver__ @@ -44,7 +44,9 @@ class assets_mixin: with io.open(path, "w", encoding="utf-8") as f: f.write(str(json.dumps(package, indent=2, ensure_ascii=False))) except (IOError) as e: - print("Error setting the version for front-end assets: " + str(e)) # noqa + print( # noqa: T201 + "Error setting the version for front-end assets: " + str(e) + ) raise SystemExit(1) @@ -77,7 +79,7 @@ class check_bdist_egg(bdist_egg): def run(self): bdist_egg.run(self) if not os.path.isdir(self.sentinel_dir): - print( # noqa + print( # noqa: T201 "\n".join( [ # noqa "************************************************************",