Skip to content
Draft
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
9 changes: 9 additions & 0 deletions packages/bigframes/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ def format(session):
*LINT_PATHS,
)

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


@nox.session(python=DEFAULT_PYTHON_VERSION)
def lint_setup_py(session):
Expand Down
29 changes: 20 additions & 9 deletions packages/bigquery-magics/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import pathlib
import re
import shutil
from typing import Dict, List
import warnings
from typing import Dict, List

import nox

FLAKE8_VERSION = "flake8==6.1.0"
BLACK_VERSION = "black[jupyter]==23.7.0"
RUFF_VERSION = "ruff==0.14.14"
ISORT_VERSION = "isort==5.11.0"
LINT_PATHS = ["docs", "bigquery_magics", "tests", "noxfile.py", "setup.py"]

Expand Down Expand Up @@ -170,19 +171,29 @@ def blacken(session):
@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
session.run(
"isort",
"--fss",
"ruff",
"check",
"--select",
"I",
"--fix",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88",
*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",
*LINT_PATHS,
)

Expand Down
30 changes: 20 additions & 10 deletions packages/db-dtypes/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import pathlib
import re
import shutil
from typing import Dict, List
import warnings
from typing import Dict, List

import nox

FLAKE8_VERSION = "flake8==6.1.0"
BLACK_VERSION = "black[jupyter]==23.7.0"
RUFF_VERSION = "ruff==0.14.14"
ISORT_VERSION = "isort==5.11.0"
LINT_PATHS = ["docs", "db_dtypes", "tests", "noxfile.py", "setup.py"]

Expand Down Expand Up @@ -122,20 +123,29 @@ def blacken(session):
@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
session.run("python", "-m", "pip", "freeze")
# 1. Install ruff (skipped automatically if you run with --no-venv)
session.install(RUFF_VERSION)

# 2. Run Ruff to fix imports
session.run(
"isort",
"--fss",
"ruff",
"check",
"--select",
"I",
"--fix",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88",
*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",
*LINT_PATHS,
)

Expand Down
33 changes: 32 additions & 1 deletion packages/google-api-core/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# PIP_INDEX_URL=https://pypi.org/simple nox

from __future__ import absolute_import

import os
import pathlib
import re
Expand All @@ -27,8 +28,8 @@
# https://github.com/google/importlab/issues/25
import nox


BLACK_VERSION = "black==23.7.0"
RUFF_VERSION = "ruff==0.14.14"
BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
# Black and flake8 clash on the syntax for ignoring flake8's F401 in this file.
BLACK_EXCLUDES = ["--exclude", "^/google/api_core/operations_v1/__init__.py"]
Expand Down Expand Up @@ -72,6 +73,36 @@ def blacken(session):
session.run("black", *BLACK_EXCLUDES, *BLACK_PATHS)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def format(session):
"""
Run ruff to sort imports and format code.
"""
# 1. Install ruff (skipped automatically if you run with --no-venv)
session.install(RUFF_VERSION)

# 2. Run Ruff to fix imports
session.run(
"ruff",
"check",
"--select",
"I",
"--fix",
f"--target-version=py{ALL_PYTHON[0].replace('.', '')}",
"--line-length=88",
*BLACK_PATHS,
)

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


def install_prerelease_dependencies(session, constraints_path):
with open(constraints_path, encoding="utf-8") as constraints_file:
constraints_text = constraints_file.read()
Expand Down
29 changes: 20 additions & 9 deletions packages/google-auth-httplib2/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
import pathlib
import re
import shutil
from typing import Dict, List
import warnings
from typing import Dict, List

import nox

FLAKE8_VERSION = "flake8==6.1.0"
BLACK_VERSION = "black[jupyter]==23.7.0"
RUFF_VERSION = "ruff==0.14.14"
ISORT_VERSION = "isort==5.11.0"
LINT_PATHS = ["docs", "google_auth_httplib2.py", "tests", "noxfile.py", "setup.py"]

Expand Down Expand Up @@ -118,19 +119,29 @@ def blacken(session):
@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
session.run(
"isort",
"--fss",
"ruff",
"check",
"--select",
"I",
"--fix",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88",
*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",
*LINT_PATHS,
)

Expand Down
29 changes: 20 additions & 9 deletions packages/google-auth-oauthlib/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import pathlib
import re
import shutil
from typing import Dict, List
import warnings
from typing import Dict, List

import nox

FLAKE8_VERSION = "flake8==6.1.0"
BLACK_VERSION = "black[jupyter]==23.7.0"
RUFF_VERSION = "ruff==0.14.14"
ISORT_VERSION = "isort==5.11.0"
LINT_PATHS = ["docs", "google_auth_oauthlib", "tests", "noxfile.py", "setup.py"]

Expand Down Expand Up @@ -103,19 +104,29 @@ def blacken(session):
@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
session.run(
"isort",
"--fss",
"ruff",
"check",
"--select",
"I",
"--fix",
f"--target-version=py{UNIT_TEST_PYTHON_VERSIONS[0].replace('.', '')}",
"--line-length=88",
*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",
*LINT_PATHS,
)

Expand Down
32 changes: 32 additions & 0 deletions packages/google-auth/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

CLICK_VERSION = "click"
BLACK_VERSION = "black==23.7.0"
RUFF_VERSION = "ruff==0.14.14"
BLACK_PATHS = [
"google",
"tests",
Expand Down Expand Up @@ -51,6 +52,7 @@
nox.options.sessions = [
"lint",
"blacken",
"format",
"mypy",
# cover must be last to avoid error `No data to report`
"docs",
Expand Down Expand Up @@ -97,6 +99,36 @@ def blacken(session):
session.run("black", *BLACK_PATHS)


@nox.session(python=DEFAULT_PYTHON_VERSION)
def format(session):
"""
Run ruff to sort imports and format code.
"""
# 1. Install ruff (skipped automatically if you run with --no-venv)
session.install(RUFF_VERSION)

# 2. Run Ruff to fix imports
session.run(
"ruff",
"check",
"--select",
"I",
"--fix",
f"--target-version=py{ALL_PYTHON[0].replace('.', '')}",
"--line-length=88",
*BLACK_PATHS,
)

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


@nox.session(python=DEFAULT_PYTHON_VERSION)
def mypy(session):
"""Verify type hints are mypy compatible."""
Expand Down
Loading
Loading