diff --git a/pyproject.toml b/pyproject.toml index 3206d143e6d1..e1a660ec9d5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ select = [ "FA", # flake8-future-annotations "I", # isort "PGH", # pygrep-hooks + "RET", # flake8-return "RUF", # Ruff-specific and unused-noqa "UP", # pyupgrade "YTT", # flake8-2020 @@ -89,11 +90,16 @@ ignore = [ ### # Rules we don't want or don't agree with ### - # Slower and more verbose https://github.com/astral-sh/ruff/issues/7871 - "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` # Used for direct, non-subclass type comparison, for example: `type(val) is str` # see https://github.com/astral-sh/ruff/issues/6465 "E721", # Do not compare types, use `isinstance()` + # `else` can be clearer to read, especially for short branches or elif chains + "RET505", # Unnecessary `{branch}` after `return` statement + "RET506", # Unnecessary `{branch}` after `raise` statement + "RET507", # Unnecessary `{branch}` after `continue` statement + "RET508", # Unnecessary `{branch}` after `break` statement + # Slower and more verbose https://github.com/astral-sh/ruff/issues/7871 + "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` ### # False-positives, but already checked by type-checkers ### diff --git a/scripts/sync_protobuf/google_protobuf.py b/scripts/sync_protobuf/google_protobuf.py index da2ced6f9fc7..2580807781b0 100644 --- a/scripts/sync_protobuf/google_protobuf.py +++ b/scripts/sync_protobuf/google_protobuf.py @@ -48,11 +48,10 @@ def extract_proto_file_paths(temp_dir: Path) -> list[str]: """ with open(temp_dir / EXTRACTED_PACKAGE_DIR / "python" / "dist" / "BUILD.bazel") as file: matched_lines = filter(None, (re.search(PROTO_FILE_PATTERN, line) for line in file)) - proto_files = [ + return [ EXTRACTED_PACKAGE_DIR + "/src/google/protobuf/" + match.group(1).replace("compiler_", "compiler/") + ".proto" for match in matched_lines ] - return proto_files def main() -> None: diff --git a/tests/runtests.py b/tests/runtests.py index 1c5ba0c18ab9..817778b23df9 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -29,8 +29,7 @@ def _parse_jsonc(json_text: str) -> str: # strip comments from the file lines = [line for line in json_text.split("\n") if not line.strip().startswith("//")] # strip trailing commas from the file - valid_json = re.sub(r",(\s*?[\}\]])", r"\1", "\n".join(lines)) - return valid_json + return re.sub(r",(\s*?[\}\]])", r"\1", "\n".join(lines)) def _get_strict_params(stub_path: str) -> list[str]: