Skip to content

Commit d88aaa6

Browse files
authored
PYTHON-5858 - Upgrade ruff from v0.1.3 to v0.15.15 (mongodb#2874)
1 parent eb42bc3 commit d88aaa6

381 files changed

Lines changed: 2245 additions & 2304 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.evergreen/scripts/generate_config_utils.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def create_variant_generic(
106106
task_refs.append(t)
107107
else:
108108
task_refs.append(EvgTaskRef(name=t))
109-
expansions = expansions and expansions.copy() or dict()
109+
expansions = (expansions and expansions.copy()) or dict()
110110
if "run_on" in kwargs:
111111
run_on = kwargs.pop("run_on")
112112
elif host:
@@ -137,15 +137,12 @@ def create_variant(
137137
expansions: dict | None = None,
138138
**kwargs: Any,
139139
) -> BuildVariant:
140-
expansions = expansions and expansions.copy() or dict()
140+
expansions = (expansions and expansions.copy()) or dict()
141141
if version:
142142
expansions["VERSION"] = version
143143
# 8.0+ Windows builds must run on win-latest
144-
if (
145-
"win64" in display_name.lower()
146-
or "win32" in display_name.lower()
147-
and version
148-
and version >= "8.0"
144+
if "win64" in display_name.lower() or (
145+
"win32" in display_name.lower() and version and version >= "8.0"
149146
):
150147
kwargs["run_on"] = HOSTS["win-latest"].run_on
151148
return create_variant_generic(
@@ -166,7 +163,7 @@ def get_versions_until(max_version: str) -> list[str]:
166163
max_version_float = float(max_version)
167164
versions = [v for v in ALL_VERSIONS if v not in ["rapid", "latest"]]
168165
versions = [v for v in versions if float(v) <= max_version_float]
169-
if not len(versions):
166+
if not versions:
170167
raise ValueError(f"No server versions found less <= {max_version}")
171168
return versions
172169

.evergreen/scripts/kms_tester.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ def setup_kms(sub_test_name: str) -> None:
9999
os.environ["AZUREKMS_VMNAME_PREFIX"] = "PYTHON_DRIVER"
100100

101101
# Found using "az vm image list --output table"
102-
os.environ[
103-
"AZUREKMS_IMAGE"
104-
] = "Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:latest"
102+
os.environ["AZUREKMS_IMAGE"] = (
103+
"Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:latest"
104+
)
105105
else:
106106
os.environ["GCPKMS_IMAGEFAMILY"] = "debian-12"
107107

@@ -127,9 +127,9 @@ def test_kms_send_to_remote(sub_test_name: str) -> None:
127127
if sub_test_name == "azure":
128128
key_name = os.environ["KEY_NAME"]
129129
key_vault_endpoint = os.environ["KEY_VAULT_ENDPOINT"]
130-
env[
131-
"AZUREKMS_CMD"
132-
] = f'KEY_NAME="{key_name}" KEY_VAULT_ENDPOINT="{key_vault_endpoint}" bash ./.evergreen/just.sh run-tests'
130+
env["AZUREKMS_CMD"] = (
131+
f'KEY_NAME="{key_name}" KEY_VAULT_ENDPOINT="{key_vault_endpoint}" bash ./.evergreen/just.sh run-tests'
132+
)
133133
else:
134134
env["GCPKMS_CMD"] = "./.evergreen/just.sh run-tests"
135135
cmd = f"{DIRS[sub_test_name]}/run-command.sh"

.evergreen/scripts/oidc_tester.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def test_oidc_send_to_remote(sub_test_name: str) -> None:
8787
if sub_test_name in ["azure", "gcp"]:
8888
upper_name = sub_test_name.upper()
8989
env[f"{upper_name}OIDC_DRIVERS_TAR_FILE"] = TMP_DRIVER_FILE
90-
env[
91-
f"{upper_name}OIDC_TEST_CMD"
92-
] = f"OIDC_ENV={sub_test_name} ./.evergreen/run-mongodb-oidc-test.sh"
90+
env[f"{upper_name}OIDC_TEST_CMD"] = (
91+
f"OIDC_ENV={sub_test_name} ./.evergreen/run-mongodb-oidc-test.sh"
92+
)
9393
elif sub_test_name in K8S_NAMES:
9494
env["K8S_DRIVERS_TAR_FILE"] = TMP_DRIVER_FILE
9595
env["K8S_TEST_CMD"] = "OIDC_ENV=k8s ./.evergreen/run-mongodb-oidc-test.sh"

.evergreen/scripts/resync-all-specs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def resync_specs(directory: pathlib.Path, errored: dict[str, str]) -> None:
2020
if spec.name in ["asynchronous"]:
2121
continue
2222
try:
23-
subprocess.run(
24-
["bash", "./.evergreen/resync-specs.sh", spec.name], # noqa: S603, S607
23+
subprocess.run( # noqa: S603
24+
["bash", "./.evergreen/resync-specs.sh", spec.name], # noqa: S607
2525
capture_output=True,
2626
text=True,
2727
check=True,
@@ -34,7 +34,7 @@ def resync_specs(directory: pathlib.Path, errored: dict[str, str]) -> None:
3434
def apply_patches(errored):
3535
print("Beginning to apply patches")
3636
subprocess.run(
37-
["bash", "./.evergreen/remove-unimplemented-tests.sh"], # noqa: S603, S607
37+
["bash", "./.evergreen/remove-unimplemented-tests.sh"], # noqa: S607
3838
check=True,
3939
)
4040
try:
@@ -46,8 +46,8 @@ def apply_patches(errored):
4646
if patches:
4747
for patch in patches:
4848
print(f"Applying patch {patch}")
49-
subprocess.run(
50-
[ # noqa: S603, S607
49+
subprocess.run( # noqa: S603
50+
[ # noqa: S607
5151
"git",
5252
"apply",
5353
"-R",
@@ -96,7 +96,7 @@ def write_summary(errored: dict[str, str], new: list[str], filename: str | None)
9696
pr_body = ""
9797
# Avoid shell=True and complex pipes by using Python to process git output
9898
process = subprocess.run(
99-
["git", "diff", "--name-only"], # noqa: S603, S607
99+
["git", "diff", "--name-only"], # noqa: S607
100100
capture_output=True,
101101
text=True,
102102
check=True,

.evergreen/scripts/run_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def run() -> None:
177177
if TEST_NAME == "doctest":
178178
from sphinx.cmd.build import main
179179

180-
result = main("-E -b doctest doc ./doc/_build/doctest".split())
180+
result = main(["-E", "-b", "doctest", "doc", "./doc/_build/doctest"])
181181
sys.exit(result)
182182

183183
# Send ecs tests to run remotely.

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020

2121
- repo: https://github.com/astral-sh/ruff-pre-commit
2222
# Ruff version.
23-
rev: v0.1.3
23+
rev: v0.15.16
2424
hooks:
2525
- id: ruff
2626
args: ["--fix", "--show-fixes"]
@@ -35,7 +35,7 @@ repos:
3535
require_serial: true
3636
fail_fast: true
3737
additional_dependencies:
38-
- ruff==0.1.3
38+
- ruff==0.15.16
3939
- unasync
4040

4141
- repo: https://github.com/adamchainz/blacken-docs

_setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def run(self):
7171
if os.environ.get("PYMONGO_C_EXT_MUST_BUILD"):
7272
raise
7373
e = sys.exc_info()[1]
74-
sys.stdout.write("%s\n" % str(e))
74+
sys.stdout.write(f"{e!s}\n")
7575
warnings.warn(
7676
self.warning_message
7777
% (
@@ -94,7 +94,7 @@ def build_extension(self, ext):
9494
if os.environ.get("PYMONGO_C_EXT_MUST_BUILD"):
9595
raise
9696
e = sys.exc_info()[1]
97-
sys.stdout.write("%s\n" % str(e))
97+
sys.stdout.write(f"{e!s}\n")
9898
warnings.warn(
9999
self.warning_message
100100
% (

0 commit comments

Comments
 (0)