-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore: update handwritten noxfiles to use ruff #15580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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"] | ||||||
|
|
||||||
|
|
@@ -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, | ||||||
| ) | ||||||
|
|
||||||
|
|
@@ -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) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment here is misleading.
Suggested change
|
||||||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The # 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,
) |
||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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"] | ||||||
|
|
||||||
|
|
@@ -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, | ||||||
| ) | ||||||
|
|
||||||
|
|
@@ -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) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment here is misleading.
Suggested change
|
||||||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The # 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,
) |
||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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"] | ||||||
|
|
||||||
|
|
@@ -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, | ||||||
| ) | ||||||
|
|
||||||
|
|
@@ -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) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment here is misleading.
Suggested change
|
||||||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The # 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,
) |
||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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"] | ||||||
|
|
||||||
|
|
@@ -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, | ||||||
| ) | ||||||
|
|
||||||
|
|
@@ -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) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment here is misleading.
Suggested change
|
||||||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The # 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,
) |
||||||
|
|
||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no
#1in this comment:Same for the other files.