Skip to content

run ruff on codebase#121

Open
Mbeaulne wants to merge 1 commit into02-24-adds_ruff_and_mypy_linting_and_type_checkingfrom
02-24-run_ruff_on_codebase
Open

run ruff on codebase#121
Mbeaulne wants to merge 1 commit into02-24-adds_ruff_and_mypy_linting_and_type_checkingfrom
02-24-run_ruff_on_codebase

Conversation

@Mbeaulne
Copy link
Collaborator

@Mbeaulne Mbeaulne commented Feb 25, 2026

TL;DR

Modernized Python code by adopting PEP 585 union syntax, consolidating imports, and applying various code style improvements.

What changed?

  • Replaced typing.Union and typing.Optional with modern union syntax (| and | None)
  • Consolidated multiple import statements from the same module into single lines
  • Removed unused imports (Optional, OrderedDict, etc.)
  • Updated type annotations to use built-in generics (list, dict, tuple) instead of typing equivalents
  • Replaced f-string formatting with direct string literals where variables weren't used
  • Simplified conditional logic in some cases (combined elif conditions)
  • Updated exception handling to remove unused exception variables
  • Modernized file opening calls by removing redundant mode specifications
  • Fixed import ordering to follow PEP 8 conventions

How to test?

Run the existing test suite to ensure all functionality remains intact. The changes are purely stylistic and should not affect runtime behavior.

Why make this change?

These changes improve code readability and maintainability while adopting modern Python conventions. The new union syntax is more concise and readable, consolidated imports reduce clutter, and removing unused imports helps with code clarity and potentially reduces import overhead.

Copy link
Collaborator Author

Mbeaulne commented Feb 25, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Mbeaulne Mbeaulne marked this pull request as ready for review February 25, 2026 01:41
@Mbeaulne Mbeaulne requested a review from Ark-kun as a code owner February 25, 2026 01:41
Copy link
Collaborator

Seems pretty good to me. Can you ask an agent if any of the changes made in the most recent commit (assuming you are checked out on this branch) are breaking changes? I'd be interested to have that peace of mind, especially given my own Python knowledge is limited and I won't be able to properly judge line by line if this is safe.

If you think it's safe, and an agent thinks it's safe, and a regression test of the API and orchestrators passes locally, then it's good with me!

@Ark-kun
Copy link
Contributor

Ark-kun commented Feb 25, 2026

Thank you for your work on improving the codebase.

There couple of notes:

run ruff

We use Black for code formatting.

Our style guide is based on Google Style guide: https://google.github.io/styleguide/pyguide.html with certain exception like using relative imports.

adopting PEP 585 union syntax

Note that the type union syntax is https://peps.python.org/pep-0604/ which was only introduced in Python 3.10.
Since Python 3.9 is EOL, I guess we can drop support. But usually we try to support users unless there is some compelling feature that we want.

Let's make sure the resulting changes work on Python 3.10 minimum version. There are some delayed type annotations that I think are only supported in later Python versions (for example, referring to the function's enclosing class).

We also use https://www.conventionalcommits.org/ . This will make it easy to generate changelogs.


from kubernetes import client as k8s_client_lib

from cloud_pipelines.orchestration.storage_providers import google_cloud_storage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually put cloud_pipelines import in a group adjacent to cloud_pipelines_backend since these are closely related projects.

request_timeout: int | tuple[int, int] = 10,
pod_name_prefix: str = "task-pod-",
gcs_client: "storage.Client | None" = None,
gcs_client: storage.Client | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which versions of Python this will work?

@Mbeaulne Mbeaulne force-pushed the 02-24-adds_ruff_and_mypy_linting_and_type_checking branch from cd632fd to 6431a39 Compare February 25, 2026 13:10
@Mbeaulne Mbeaulne force-pushed the 02-24-run_ruff_on_codebase branch 2 times, most recently from 8c96ada to e72e2ef Compare February 25, 2026 13:11
@Mbeaulne Mbeaulne force-pushed the 02-24-adds_ruff_and_mypy_linting_and_type_checking branch from 6431a39 to dec4dc7 Compare February 25, 2026 18:34
@Mbeaulne Mbeaulne force-pushed the 02-24-run_ruff_on_codebase branch from e72e2ef to 8d58045 Compare February 25, 2026 18:34
@Mbeaulne Mbeaulne force-pushed the 02-24-adds_ruff_and_mypy_linting_and_type_checking branch from dec4dc7 to 3163fa5 Compare February 25, 2026 18:52
@Mbeaulne Mbeaulne force-pushed the 02-24-run_ruff_on_codebase branch from 8d58045 to 101fd7b Compare February 25, 2026 18:52
Copy link
Collaborator

@morgan-wowk morgan-wowk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment and trust you can do the necessary safety checks before merging / after you have addressed Alexey's comments

@Mbeaulne Mbeaulne force-pushed the 02-24-run_ruff_on_codebase branch from 101fd7b to 560525e Compare February 25, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants