Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bumps to ruff==0.9.2 and mypy==1.14.1 #16916

Merged
merged 9 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.2.1"
rev: v0.9.2
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Relevant change

hooks:
- id: ruff
language_version: python3
Expand Down
3 changes: 1 addition & 2 deletions docs/myproject/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@


@task
def my_background_task(name: str):
...
def my_background_task(name: str): ...
12 changes: 6 additions & 6 deletions flows/check_output_of_interrupted_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ async def main():

# Check if each expected message is in the corresponding line
for expected in expected_messages:
assert (
expected in stderr_output
), f"Expected '{expected}' not found in '{stderr_output}'"
assert expected in stderr_output, (
f"Expected '{expected}' not found in '{stderr_output}'"
)

for unexpected in unexpected_messages:
assert (
unexpected not in stderr_output
), f"Unexpected '{unexpected}' found in '{stderr_output}'"
assert unexpected not in stderr_output, (
f"Unexpected '{unexpected}' found in '{stderr_output}'"
)

print("All expected log messages were found")

Expand Down
4 changes: 2 additions & 2 deletions flows/load_flows_concurrently.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ async def run_stress_test():
for i in range(10): # Run 10 iterations
try:
count = await test_iteration()
print(f"Iteration {i+1}: Successfully loaded {count} flows")
print(f"Iteration {i + 1}: Successfully loaded {count} flows")
except Exception as e:
print(f"Iteration {i+1}: Failed with error: {str(e)}")
print(f"Iteration {i + 1}: Failed with error: {str(e)}")
return False
return True

Expand Down
6 changes: 3 additions & 3 deletions flows/serve_a_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def count_runs(counter_dir: Path):

actual_run_count = count_runs(counter_dir)

assert (
actual_run_count >= MINIMUM_EXPECTED_N_FLOW_RUNS
), f"Expected at least {MINIMUM_EXPECTED_N_FLOW_RUNS} flow runs, got {actual_run_count}"
assert actual_run_count >= MINIMUM_EXPECTED_N_FLOW_RUNS, (
f"Expected at least {MINIMUM_EXPECTED_N_FLOW_RUNS} flow runs, got {actual_run_count}"
)

print(f"Successfully completed and audited {actual_run_count} flow runs")
18 changes: 9 additions & 9 deletions flows/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def main():
except subprocess.CalledProcessError as e:
# Check that the error message contains kubernetes worker type
for type in ["process", "kubernetes"]:
assert type in str(
e.output
), f"Worker type {type!r} missing from output {e.output}"
assert type in str(e.output), (
f"Worker type {type!r} missing from output {e.output}"
)

subprocess.check_call(
["prefect", "work-pool", "create", "test-worker-pool", "-t", "kubernetes"],
Expand Down Expand Up @@ -87,9 +87,9 @@ def main():
)

worker_events = [e for e in events if e.event.startswith("prefect.worker.")]
assert (
len(worker_events) == 2
), f"Expected 2 worker events, got {len(worker_events)}"
assert len(worker_events) == 2, (
f"Expected 2 worker events, got {len(worker_events)}"
)

start_events = [e for e in worker_events if e.event == "prefect.worker.started"]
stop_events = [e for e in worker_events if e.event == "prefect.worker.stopped"]
Expand All @@ -99,9 +99,9 @@ def main():

print("Captured expected worker start and stop events!")

assert (
stop_events[0].follows == start_events[0].id
), "Stop event should follow start event"
assert stop_events[0].follows == start_events[0].id, (
"Stop event should follow start event"
)


if __name__ == "__main__":
Expand Down
10 changes: 7 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
ruff
cairosvg
codespell>=2.2.6
ipython
jinja2
moto >= 5
mypy >= 1.9.0
numpy
pillow
pre-commit
Expand All @@ -23,11 +21,17 @@ redis>=5.0.1
setuptools
uv>=0.4.5
vale
vermin
virtualenv
watchfiles
respx

# Linters and dev tools that are also in .pre-commit-config.yaml, which
# should usually be updated together.
codespell==2.2.6
ruff==0.9.2
mypy==1.9.0
vermin==1.6.0

# type stubs
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Relevant changes

types-cachetools
types-PyYAML
Expand Down
1 change: 1 addition & 0 deletions scripts/generate-lower-bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
pip install $(generate-lower-bounds.py | tr "\n" " ")

"""

import re
import sys

Expand Down
6 changes: 3 additions & 3 deletions scripts/generate_settings_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def generate(self, schema, mode="validation"):
json_schema = super().generate(schema, mode=mode)
json_schema["title"] = "Prefect Settings"
json_schema["$schema"] = self.schema_dialect
json_schema[
"$id"
] = "https://github.com/PrefectHQ/prefect/schemas/settings.schema.json"
json_schema["$id"] = (
"https://github.com/PrefectHQ/prefect/schemas/settings.schema.json"
)
return json_schema


Expand Down
1 change: 0 additions & 1 deletion scripts/wait-for-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
PREFECT_API_URL="http://localhost:4200" ./scripts/wait-for-server.py
"""


import sys

import anyio
Expand Down
6 changes: 3 additions & 3 deletions src/integrations/prefect-aws/prefect_aws/secrets_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ def example_delete_secret_with_recovery_window():

delete_secret_kwargs: Dict[str, Union[str, int, bool]] = dict(SecretId=secret_name)
if force_delete_without_recovery:
delete_secret_kwargs[
"ForceDeleteWithoutRecovery"
] = force_delete_without_recovery
delete_secret_kwargs["ForceDeleteWithoutRecovery"] = (
force_delete_without_recovery
)
else:
delete_secret_kwargs["RecoveryWindowInDays"] = recovery_window_in_days

Expand Down
18 changes: 9 additions & 9 deletions src/integrations/prefect-aws/prefect_aws/workers/ecs_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,9 @@ def _watch_task_and_get_exit_code(

# Check the status code of the Prefect container
container = _get_container(task["containers"], container_name)
assert (
container is not None
), f"'{container_name}' container missing from task: {task}"
assert container is not None, (
f"'{container_name}' container missing from task: {task}"
)
status_code = container.get("exitCode")
self._report_container_status_code(logger, container_name, status_code)

Expand Down Expand Up @@ -1552,12 +1552,12 @@ def _prepare_task_run_request(
and configuration.network_configuration
and configuration.vpc_id
):
task_run_request[
"networkConfiguration"
] = self._custom_network_configuration(
configuration.vpc_id,
configuration.network_configuration,
configuration,
task_run_request["networkConfiguration"] = (
self._custom_network_configuration(
configuration.vpc_id,
configuration.network_configuration,
configuration,
)
)

# Ensure the container name is set if not provided at template time
Expand Down
18 changes: 9 additions & 9 deletions src/integrations/prefect-aws/tests/test_client_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ def test_get_params_override_with_both_cert_path(self, tmp_path):
def test_get_params_override_with_default_verify(self):
params = AwsClientParameters()
override_params = params.get_params_override()
assert (
"verify" not in override_params
), "verify should not be in params_override when not explicitly set"
assert "verify" not in override_params, (
"verify should not be in params_override when not explicitly set"
)

def test_get_params_override_with_explicit_verify(self):
params_true = AwsClientParameters(verify=True)
Expand All @@ -142,12 +142,12 @@ def test_get_params_override_with_explicit_verify(self):
override_params_true = params_true.get_params_override()
override_params_false = params_false.get_params_override()

assert (
"verify" in override_params_true
), "verify should be in params_override when explicitly set to True"
assert "verify" in override_params_true, (
"verify should be in params_override when explicitly set to True"
)
assert override_params_true["verify"] is True

assert (
"verify" in override_params_false
), "verify should be in params_override when explicitly set to False"
assert "verify" in override_params_false, (
"verify should be in params_override when explicitly set to False"
)
assert override_params_false["verify"] is False
12 changes: 6 additions & 6 deletions src/integrations/prefect-aws/tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def test_aws_credentials_change_causes_cache_miss(client_type):

new_client = credentials.get_client(client_type)

assert (
initial_client is not new_client
), "Client should be different after configuration change"
assert initial_client is not new_client, (
"Client should be different after configuration change"
)

assert _get_client_cached.cache_info().misses == 2, "Cache should miss twice"

Expand All @@ -125,9 +125,9 @@ def test_minio_credentials_change_causes_cache_miss(client_type):

new_client = credentials.get_client(client_type)

assert (
initial_client is not new_client
), "Client should be different after configuration change"
assert initial_client is not new_client, (
"Client should be different after configuration change"
)

assert _get_client_cached.cache_info().misses == 2, "Cache should miss twice"

Expand Down
6 changes: 3 additions & 3 deletions src/integrations/prefect-aws/tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,9 +1138,9 @@ def test_round_trip_default_credentials(self):
# https://github.com/PrefectHQ/prefect/issues/13349
S3Bucket(bucket_name="round-trip-bucket").save("round-tripper")
loaded = S3Bucket.load("round-tripper")
assert hasattr(
loaded.credentials, "aws_access_key_id"
), "`credentials` were not properly initialized"
assert hasattr(loaded.credentials, "aws_access_key_id"), (
"`credentials` were not properly initialized"
)

@pytest.mark.parametrize(
"client_parameters",
Expand Down
30 changes: 15 additions & 15 deletions src/integrations/prefect-aws/tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
class TestHashCollection:
def test_simple_dict(self):
simple_dict = {"key1": "value1", "key2": "value2"}
assert hash_collection(simple_dict) == hash_collection(
simple_dict
), "Simple dictionary hashing failed"
assert hash_collection(simple_dict) == hash_collection(simple_dict), (
"Simple dictionary hashing failed"
)

def test_nested_dict(self):
nested_dict = {"key1": {"subkey1": "subvalue1"}, "key2": "value2"}
assert hash_collection(nested_dict) == hash_collection(
nested_dict
), "Nested dictionary hashing failed"
assert hash_collection(nested_dict) == hash_collection(nested_dict), (
"Nested dictionary hashing failed"
)

def test_complex_structure(self):
complex_structure = {
Expand Down Expand Up @@ -57,9 +57,9 @@ def test_existing_path(self):
doc = {"key1": {"subkey1": "value1"}}
path = ["key1", "subkey1"]
ensure_path_exists(doc, path)
assert doc == {
"key1": {"subkey1": "value1"}
}, "Existing path modification failed"
assert doc == {"key1": {"subkey1": "value1"}}, (
"Existing path modification failed"
)

def test_new_path_object(self):
doc = {}
Expand All @@ -77,14 +77,14 @@ def test_existing_path_array(self):
doc = {"key1": [{"subkey1": "value1"}]}
path = ["key1", "0", "subkey1"]
ensure_path_exists(doc, path)
assert doc == {
"key1": [{"subkey1": "value1"}]
}, "Existing path modification for array failed"
assert doc == {"key1": [{"subkey1": "value1"}]}, (
"Existing path modification for array failed"
)

def test_existing_path_array_index_out_of_range(self):
doc = {"key1": []}
path = ["key1", "0", "subkey1"]
ensure_path_exists(doc, path)
assert doc == {
"key1": [{"subkey1": {}}]
}, "Existing path modification for array index out of range failed"
assert doc == {"key1": [{"subkey1": {}}]}, (
"Existing path modification for array index out of range failed"
)
Loading
Loading