Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 32 additions & 15 deletions packages/google-cloud-access-context-manager/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

import nox

BLACK_VERSION = "black[jupyter]==23.7.0"
ISORT_VERSION = "isort==5.11.0"
RUFF_VERSION = "ruff==0.14.14"

LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]

Expand Down Expand Up @@ -102,10 +101,14 @@ def lint(session):
Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.install("flake8", BLACK_VERSION)
session.install("flake8", RUFF_VERSION)

# 2. Check formatting
Copy link
Contributor

@vchudnov-g vchudnov-g Feb 18, 2026

Choose a reason for hiding this comment

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

There is no #1 in this comment:

Suggested change
# 2. Check formatting
# Check formatting

Same for the other files.

session.run(
"black",
"ruff", "format",
"--check",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88",
*LINT_PATHS,
)

Expand All @@ -114,30 +117,44 @@ def lint(session):

@nox.session(python=DEFAULT_PYTHON_VERSION)
def blacken(session):
"""Run black. Format code to uniform standard."""
session.install(BLACK_VERSION)
"""(Deprecated) Legacy session. Please use 'nox -s format'."""
session.log("WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future.")

# Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The comment here is misleading. ruff format also sorts imports, so it's not keeping the legacy behavior of black which only formats. Since this session is deprecated, changing the behavior is acceptable, but the comment should be updated to be accurate.

Suggested change
# Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports)
# Just run the ruff formatter (which also sorts imports)

session.install(RUFF_VERSION)
session.run(
"black",
"ruff", "format",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88",
*LINT_PATHS,
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def format(session):
"""
Run isort to sort imports. Then run black
to format code to uniform standard.
Run ruff to sort imports and format code.
"""
session.install(BLACK_VERSION, ISORT_VERSION)
# Use the --fss option to sort imports using strict alphabetical order.
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
# 1. Install ruff (skipped automatically if you run with --no-venv)
session.install(RUFF_VERSION)

# 2. Run Ruff to fix imports
# check --select I: Enables strict import sorting
# --fix: Applies the changes automatically
session.run(
"isort",
"--fss",
"ruff", "check",
"--select", "I",
"--fix",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88", # Standard Black line length
*LINT_PATHS,
)

# 3. Run Ruff to format code
session.run(
"black",
"ruff", "format",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88", # Standard Black line length
*LINT_PATHS,
)
Comment on lines +141 to 159
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The ruff format command is capable of both formatting code and sorting imports. Running ruff check --select I --fix followed by ruff format is redundant and less efficient as it processes files twice. You can simplify this session by using a single ruff format command to handle both tasks.

    # 2. Run Ruff to format code and sort imports
    session.run(
        "ruff",
        "format",
        f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
        "--line-length=88",
        *LINT_PATHS,
    )


Expand Down
47 changes: 32 additions & 15 deletions packages/google-cloud-audit-log/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

import nox

BLACK_VERSION = "black[jupyter]==23.7.0"
ISORT_VERSION = "isort==5.11.0"
RUFF_VERSION = "ruff==0.14.14"

LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]

Expand Down Expand Up @@ -102,10 +101,14 @@ def lint(session):
Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.install("flake8", BLACK_VERSION)
session.install("flake8", RUFF_VERSION)

# 2. Check formatting
session.run(
"black",
"ruff", "format",
"--check",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88",
*LINT_PATHS,
)

Expand All @@ -114,30 +117,44 @@ def lint(session):

@nox.session(python=DEFAULT_PYTHON_VERSION)
def blacken(session):
"""Run black. Format code to uniform standard."""
session.install(BLACK_VERSION)
"""(Deprecated) Legacy session. Please use 'nox -s format'."""
session.log("WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future.")

# Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The comment here is misleading. ruff format also sorts imports, so it's not keeping the legacy behavior of black which only formats. Since this session is deprecated, changing the behavior is acceptable, but the comment should be updated to be accurate.

Suggested change
# Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports)
# Just run the ruff formatter (which also sorts imports)

session.install(RUFF_VERSION)
session.run(
"black",
"ruff", "format",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88",
*LINT_PATHS,
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def format(session):
"""
Run isort to sort imports. Then run black
to format code to uniform standard.
Run ruff to sort imports and format code.
"""
session.install(BLACK_VERSION, ISORT_VERSION)
# Use the --fss option to sort imports using strict alphabetical order.
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
# 1. Install ruff (skipped automatically if you run with --no-venv)
session.install(RUFF_VERSION)

# 2. Run Ruff to fix imports
# check --select I: Enables strict import sorting
# --fix: Applies the changes automatically
session.run(
"isort",
"--fss",
"ruff", "check",
"--select", "I",
"--fix",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88", # Standard Black line length
*LINT_PATHS,
)

# 3. Run Ruff to format code
session.run(
"black",
"ruff", "format",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88", # Standard Black line length
*LINT_PATHS,
)
Comment on lines +141 to 159
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The ruff format command is capable of both formatting code and sorting imports. Running ruff check --select I --fix followed by ruff format is redundant and less efficient as it processes files twice. You can simplify this session by using a single ruff format command to handle both tasks.

    # 2. Run Ruff to format code and sort imports
    session.run(
        "ruff",
        "format",
        f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
        "--line-length=88",
        *LINT_PATHS,
    )


Expand Down
47 changes: 32 additions & 15 deletions packages/google-cloud-translate/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

import nox

BLACK_VERSION = "black[jupyter]==23.7.0"
ISORT_VERSION = "isort==5.11.0"
RUFF_VERSION = "ruff==0.14.14"

LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]

Expand Down Expand Up @@ -149,10 +148,14 @@ def lint(session):
Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.install("flake8", BLACK_VERSION)
session.install("flake8", RUFF_VERSION)

# 2. Check formatting
session.run(
"black",
"ruff", "format",
"--check",
f"--target-version=py{ALL_PYTHON[0].replace('.', '')}",
"--line-length=88",
*LINT_PATHS,
)

Expand All @@ -161,30 +164,44 @@ def lint(session):

@nox.session(python=DEFAULT_PYTHON_VERSION)
def blacken(session):
"""Run black. Format code to uniform standard."""
session.install(BLACK_VERSION)
"""(Deprecated) Legacy session. Please use 'nox -s format'."""
session.log("WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future.")

# Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The comment here is misleading. ruff format also sorts imports, so it's not keeping the legacy behavior of black which only formats. Since this session is deprecated, changing the behavior is acceptable, but the comment should be updated to be accurate.

Suggested change
# Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports)
# Just run the ruff formatter (which also sorts imports)

session.install(RUFF_VERSION)
session.run(
"black",
"ruff", "format",
f"--target-version=py{ALL_PYTHON[0].replace('.', '')}",
"--line-length=88",
*LINT_PATHS,
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def format(session):
"""
Run isort to sort imports. Then run black
to format code to uniform standard.
Run ruff to sort imports and format code.
"""
session.install(BLACK_VERSION, ISORT_VERSION)
# Use the --fss option to sort imports using strict alphabetical order.
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
# 1. Install ruff (skipped automatically if you run with --no-venv)
session.install(RUFF_VERSION)

# 2. Run Ruff to fix imports
# check --select I: Enables strict import sorting
# --fix: Applies the changes automatically
session.run(
"isort",
"--fss",
"ruff", "check",
"--select", "I",
"--fix",
f"--target-version=py{ALL_PYTHON[0].replace('.', '')}",
"--line-length=88", # Standard Black line length
*LINT_PATHS,
)

# 3. Run Ruff to format code
session.run(
"black",
"ruff", "format",
f"--target-version=py{ALL_PYTHON[0].replace('.', '')}",
"--line-length=88", # Standard Black line length
*LINT_PATHS,
)
Comment on lines +188 to 206
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The ruff format command is capable of both formatting code and sorting imports. Running ruff check --select I --fix followed by ruff format is redundant and less efficient as it processes files twice. You can simplify this session by using a single ruff format command to handle both tasks.

    # 2. Run Ruff to format code and sort imports
    session.run(
        "ruff",
        "format",
        f"--target-version=py{ALL_PYTHON[0].replace('.', '')}",
        "--line-length=88",
        *LINT_PATHS,
    )


Expand Down
47 changes: 32 additions & 15 deletions packages/googleapis-common-protos/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

import nox

BLACK_VERSION = "black[jupyter]==23.7.0"
ISORT_VERSION = "isort==5.11.0"
RUFF_VERSION = "ruff==0.14.14"

LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]

Expand Down Expand Up @@ -102,10 +101,14 @@ def lint(session):
Returns a failure if the linters find linting errors or sufficiently
serious code quality issues.
"""
session.install("flake8", BLACK_VERSION)
session.install("flake8", RUFF_VERSION)

# 2. Check formatting
session.run(
"black",
"ruff", "format",
"--check",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88",
*LINT_PATHS,
)

Expand All @@ -114,30 +117,44 @@ def lint(session):

@nox.session(python=DEFAULT_PYTHON_VERSION)
def blacken(session):
"""Run black. Format code to uniform standard."""
session.install(BLACK_VERSION)
"""(Deprecated) Legacy session. Please use 'nox -s format'."""
session.log("WARNING: The 'blacken' session is deprecated and will be removed in a future release. Please use 'nox -s format' in the future.")

# Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The comment here is misleading. ruff format also sorts imports, so it's not keeping the legacy behavior of black which only formats. Since this session is deprecated, changing the behavior is acceptable, but the comment should be updated to be accurate.

Suggested change
# Just run the ruff formatter (keeping legacy behavior of only formatting, not sorting imports)
# Just run the ruff formatter (which also sorts imports)

session.install(RUFF_VERSION)
session.run(
"black",
"ruff", "format",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88",
*LINT_PATHS,
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def format(session):
"""
Run isort to sort imports. Then run black
to format code to uniform standard.
Run ruff to sort imports and format code.
"""
session.install(BLACK_VERSION, ISORT_VERSION)
# Use the --fss option to sort imports using strict alphabetical order.
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
# 1. Install ruff (skipped automatically if you run with --no-venv)
session.install(RUFF_VERSION)

# 2. Run Ruff to fix imports
# check --select I: Enables strict import sorting
# --fix: Applies the changes automatically
session.run(
"isort",
"--fss",
"ruff", "check",
"--select", "I",
"--fix",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88", # Standard Black line length
*LINT_PATHS,
)

# 3. Run Ruff to format code
session.run(
"black",
"ruff", "format",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88", # Standard Black line length
*LINT_PATHS,
)
Comment on lines +141 to 159
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The ruff format command is capable of both formatting code and sorting imports. Running ruff check --select I --fix followed by ruff format is redundant and less efficient as it processes files twice. You can simplify this session by using a single ruff format command to handle both tasks.

    # 2. Run Ruff to format code and sort imports
    session.run(
        "ruff",
        "format",
        f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
        "--line-length=88",
        *LINT_PATHS,
    )


Expand Down
Loading
Loading