-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Ruff 0.8 #14383
Ruff 0.8 #14383
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
TCH001 | 354 | 0 | 354 | 0 | 0 |
TC001 | 352 | 352 | 0 | 0 | 0 |
TC003 | 202 | 202 | 0 | 0 | 0 |
TCH003 | 202 | 0 | 202 | 0 | 0 |
RUF023 | 167 | 167 | 0 | 0 | 0 |
TC002 | 147 | 147 | 0 | 0 | 0 |
TCH002 | 147 | 0 | 147 | 0 | 0 |
RUF022 | 146 | 146 | 0 | 0 | 0 |
UP006 | 145 | 145 | 0 | 0 | 0 |
UP035 | 71 | 71 | 0 | 0 | 0 |
A004 | 66 | 66 | 0 | 0 | 0 |
RUF021 | 64 | 64 | 0 | 0 | 0 |
UP031 | 62 | 62 | 0 | 0 | 0 |
RUF101 | 46 | 46 | 0 | 0 | 0 |
PLC0206 | 43 | 43 | 0 | 0 | 0 |
PYI063 | 5 | 5 | 0 | 0 | 0 |
B039 | 4 | 4 | 0 | 0 | 0 |
PT004 | 3 | 0 | 3 | 0 | 0 |
RUF200 | 2 | 2 | 0 | 0 | 0 |
D212 | 2 | 1 | 1 | 0 | 0 |
TC005 | 2 | 2 | 0 | 0 | 0 |
TCH005 | 2 | 0 | 2 | 0 | 0 |
RUF100 | 1 | 1 | 0 | 0 | 0 |
A001 | 1 | 0 | 1 | 0 | 0 |
TCH004 | 1 | 0 | 1 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+1003 -740 violations, +0 -0 fixes in 12 projects; 42 projects unchanged)
apache/airflow (+125 -119 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ airflow/__main__.py:25:22: TC003 Move standard library import `argparse.Namespace` into a type-checking block - airflow/__main__.py:25:22: TCH003 Move standard library import `argparse.Namespace` into a type-checking block + airflow/api_connexion/schemas/asset_schema.py:19:22: TC003 Move standard library import `datetime.datetime` into a type-checking block - airflow/api_connexion/schemas/asset_schema.py:19:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block + airflow/api_fastapi/common/parameters.py:21:22: TC003 Move standard library import `datetime.datetime` into a type-checking block - airflow/api_fastapi/common/parameters.py:21:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block + airflow/api_fastapi/common/router.py:20:18: TC003 Move standard library import `enum.Enum` into a type-checking block - airflow/api_fastapi/common/router.py:20:18: TCH003 Move standard library import `enum.Enum` into a type-checking block + airflow/api_fastapi/common/types.py:19:22: TC003 Move standard library import `datetime.timedelta` into a type-checking block - airflow/api_fastapi/common/types.py:19:22: TCH003 Move standard library import `datetime.timedelta` into a type-checking block ... 234 additional changes omitted for project
apache/superset (+321 -321 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ superset/advanced_data_type/api.py:28:47: TC001 Move application import `superset.advanced_data_type.types.AdvancedDataTypeResponse` into a type-checking block - superset/advanced_data_type/api.py:28:47: TCH001 Move application import `superset.advanced_data_type.types.AdvancedDataTypeResponse` into a type-checking block + superset/async_events/async_query_manager.py:26:41: TC002 Move third-party import `flask_caching.backends.base.BaseCache` into a type-checking block - superset/async_events/async_query_manager.py:26:41: TCH002 Move third-party import `flask_caching.backends.base.BaseCache` into a type-checking block + superset/charts/data/api.py:43:45: TC001 Move application import `superset.connectors.sqla.models.BaseDatasource` into a type-checking block - superset/charts/data/api.py:43:45: TCH001 Move application import `superset.connectors.sqla.models.BaseDatasource` into a type-checking block + superset/charts/data/api.py:47:37: TC001 Move application import `superset.models.sql_lab.Query` into a type-checking block - superset/charts/data/api.py:47:37: TCH001 Move application import `superset.models.sql_lab.Query` into a type-checking block + superset/cli/test_db.py:45:43: TC001 Move application import `superset.db_engine_specs.base.BaseEngineSpec` into a type-checking block - superset/cli/test_db.py:45:43: TCH001 Move application import `superset.db_engine_specs.base.BaseEngineSpec` into a type-checking block + superset/commands/annotation_layer/annotation/create.py:18:22: TC003 Move standard library import `datetime.datetime` into a type-checking block - superset/commands/annotation_layer/annotation/create.py:18:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block + superset/commands/annotation_layer/annotation/create.py:23:25: TC002 Move third-party import `marshmallow.ValidationError` into a type-checking block - superset/commands/annotation_layer/annotation/create.py:23:25: TCH002 Move third-party import `marshmallow.ValidationError` into a type-checking block + superset/commands/annotation_layer/annotation/delete.py:27:41: TC001 Move application import `superset.models.annotations.Annotation` into a type-checking block - superset/commands/annotation_layer/annotation/delete.py:27:41: TCH001 Move application import `superset.models.annotations.Annotation` into a type-checking block + superset/commands/annotation_layer/annotation/update.py:18:22: TC003 Move standard library import `datetime.datetime` into a type-checking block - superset/commands/annotation_layer/annotation/update.py:18:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block ... 624 additional changes omitted for project
bokeh/bokeh (+232 -232 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL
+ release/build.py:18:21: TC001 Move application import `.config.Config` into a type-checking block - release/build.py:18:21: TCH001 Move application import `.config.Config` into a type-checking block + release/build.py:19:21: TC001 Move application import `.system.System` into a type-checking block - release/build.py:19:21: TCH001 Move application import `.system.System` into a type-checking block + release/checks.py:19:21: TC001 Move application import `.config.Config` into a type-checking block - release/checks.py:19:21: TCH001 Move application import `.config.Config` into a type-checking block + release/checks.py:20:23: TC001 Move application import `.pipeline.StepType` into a type-checking block - release/checks.py:20:23: TCH001 Move application import `.pipeline.StepType` into a type-checking block + release/checks.py:21:21: TC001 Move application import `.system.System` into a type-checking block - release/checks.py:21:21: TCH001 Move application import `.system.System` into a type-checking block + release/credentials.py:24:21: TC001 Move application import `.config.Config` into a type-checking block ... 189 additional changes omitted for rule TC001 - release/credentials.py:24:21: TCH001 Move application import `.config.Config` into a type-checking block ... 189 additional changes omitted for rule TCH001 + src/bokeh/application/handlers/code.py:41:19: TC003 Move standard library import `types.ModuleType` into a type-checking block ... 451 additional changes omitted for project
ibis-project/ibis (+42 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
+ ibis/backends/oracle/tests/test_client.py:3:36: RUF101 [*] `TCH003` is a redirect to `TC003` + ibis/backends/polars/rewrites.py:10:50: RUF101 [*] `TCH001` is a redirect to `TC001` + ibis/backends/sql/rewrites.py:17:57: RUF101 [*] `TCH001` is a redirect to `TC001` + ibis/backends/sql/rewrites.py:21:50: RUF101 [*] `TCH001` is a redirect to `TC001` + ibis/common/grounds.py:29:57: RUF101 [*] `TCH001` is a redirect to `TC001` + ibis/common/selectors.py:8:50: RUF101 [*] `TCH001` is a redirect to `TC001` + ibis/config.py:3:47: RUF101 [*] `TCH003` is a redirect to `TC003` + ibis/expr/builders.py:16:53: RUF101 [*] `TCH001` is a redirect to `TC001` + ibis/expr/builders.py:17:50: RUF101 [*] `TCH001` is a redirect to `TC001` + ibis/expr/datatypes/tests/test_core.py:3:26: RUF101 [*] `TCH003` is a redirect to `TC003` ... 32 additional changes omitted for project
latchbio/latch (+6 -6 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
+ src/latch/ldata/_transfer/upload.py:10:38: TC003 Move standard library import `multiprocessing.managers.DictProxy` into a type-checking block - src/latch/ldata/_transfer/upload.py:10:38: TCH003 Move standard library import `multiprocessing.managers.DictProxy` into a type-checking block + src/latch/ldata/_transfer/upload.py:10:49: TC003 Move standard library import `multiprocessing.managers.ListProxy` into a type-checking block - src/latch/ldata/_transfer/upload.py:10:49: TCH003 Move standard library import `multiprocessing.managers.ListProxy` into a type-checking block + src/latch/ldata/_transfer/upload.py:12:19: TC003 Move standard library import `queue.Queue` into a type-checking block - src/latch/ldata/_transfer/upload.py:12:19: TCH003 Move standard library import `queue.Queue` into a type-checking block + src/latch/registry/record.py:18:49: TC001 Move application import `latch.registry.upstream_types.types.DBType` into a type-checking block - src/latch/registry/record.py:18:49: TCH001 Move application import `latch.registry.upstream_types.types.DBType` into a type-checking block + src/latch_cli/services/register/utils.py:5:8: TC003 Move standard library import `io` into a type-checking block - src/latch_cli/services/register/utils.py:5:8: TCH003 Move standard library import `io` into a type-checking block ... 2 additional changes omitted for project
lnbits/lnbits (+216 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
+ lnbits/app.py:257:6: UP006 Use `list` instead of `List` for type annotation + lnbits/app.py:9:1: UP035 `typing.List` is deprecated, use `list` instead + lnbits/commands.py:235:23: UP006 Use `list` instead of `List` for type annotation + lnbits/commands.py:465:6: UP006 Use `tuple` instead of `Tuple` for type annotation + lnbits/commands.py:494:6: UP006 Use `tuple` instead of `Tuple` for type annotation + lnbits/commands.py:6:1: UP035 `typing.List` is deprecated, use `list` instead + lnbits/commands.py:6:1: UP035 `typing.Tuple` is deprecated, use `tuple` instead + lnbits/core/crud.py:1018:6: UP006 Use `list` instead of `List` for type annotation + lnbits/core/crud.py:1235:43: UP006 Use `list` instead of `List` for type annotation ... 140 additional changes omitted for rule UP006 + lnbits/core/crud.py:4:1: UP035 `typing.Dict` is deprecated, use `dict` instead ... 206 additional changes omitted for project
pandas-dev/pandas (+3 -4 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
- pandas/_typing.py:276:20: PYI063 Use PEP 570 syntax for positional-only arguments + pandas/_typing.py:276:20: PYI063 Use PEP 570 syntax for positional-only parameters - pandas/_typing.py:291:20: PYI063 Use PEP 570 syntax for positional-only arguments + pandas/_typing.py:291:20: PYI063 Use PEP 570 syntax for positional-only parameters - pandas/_typing.py:297:21: PYI063 Use PEP 570 syntax for positional-only arguments + pandas/_typing.py:297:21: PYI063 Use PEP 570 syntax for positional-only parameters ... 1 additional changes omitted for rule PYI063 - pandas/core/dtypes/dtypes.py:76:23: TCH004 Move import `pyarrow` out of type-checking block. Import is used for more than type hinting.
pypa/cibuildwheel (+2 -2 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
+ bin/bump_version.py:20:4: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons - bin/bump_version.py:20:4: PYI066 Use `>=` when using `if`-`else` with `sys.version_info` comparisons + cibuildwheel/_compat/typing.py:5:4: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons - cibuildwheel/_compat/typing.py:5:4: PYI066 Use `>=` when using `if`-`else` with `sys.version_info` comparisons
... Truncated remaining completed project reports due to GitHub comment length restrictions
Changes by rule (15 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
TC001 | 352 | 352 | 0 | 0 | 0 |
TCH001 | 352 | 0 | 352 | 0 | 0 |
TC003 | 202 | 202 | 0 | 0 | 0 |
TCH003 | 202 | 0 | 202 | 0 | 0 |
TC002 | 147 | 147 | 0 | 0 | 0 |
TCH002 | 147 | 0 | 147 | 0 | 0 |
UP006 | 145 | 145 | 0 | 0 | 0 |
UP035 | 71 | 71 | 0 | 0 | 0 |
PYI066 | 62 | 31 | 31 | 0 | 0 |
RUF101 | 46 | 46 | 0 | 0 | 0 |
PYI063 | 10 | 5 | 5 | 0 | 0 |
RUF200 | 2 | 2 | 0 | 0 | 0 |
TC005 | 2 | 2 | 0 | 0 | 0 |
TCH005 | 2 | 0 | 2 | 0 | 0 |
TCH004 | 1 | 0 | 1 | 0 | 0 |
Formatter (stable)
ℹ️ ecosystem check detected format changes. (+111 -85 lines in 16 files in 4 projects; 50 projects unchanged)
aws/aws-sam-cli (+34 -30 lines across 4 files)
tests/integration/pipeline/test_init_command.py~L98
self.assertEqual(init_process_execute.process.returncode, 0)
- with open(EXPECTED_JENKINS_FILE_PATH, "r") as expected, open(
- os.path.join(".aws-sam", "pipeline", "generated-files", "Jenkinsfile"), "r"
- ) as output:
+ with (
+ open(EXPECTED_JENKINS_FILE_PATH, "r") as expected,
+ open(os.path.join(".aws-sam", "pipeline", "generated-files", "Jenkinsfile"), "r") as output,
+ ):
self.assertEqual(expected.read(), output.read())
# also check the Jenkinsfile is not overridden
tests/unit/commands/samconfig/test_samconfig.py~L1066
}
# NOTE: Because we don't load the full Click BaseCommand here, this is mounted as top-level command
- with samconfig_parameters(
- ["start-lambda"], self.scratch_dir, **config_values
- ) as config_path, tempfile.NamedTemporaryFile() as key_file, tempfile.NamedTemporaryFile() as cert_file:
+ with (
+ samconfig_parameters(["start-lambda"], self.scratch_dir, **config_values) as config_path,
+ tempfile.NamedTemporaryFile() as key_file,
+ tempfile.NamedTemporaryFile() as cert_file,
+ ):
from samcli.commands.local.start_lambda.cli import cli
LOG.debug(Path(config_path).read_text())
tests/unit/commands/samconfig/test_samconfig.py~L1171
}
# NOTE: Because we don't load the full Click BaseCommand here, this is mounted as top-level command
- with samconfig_parameters(
- ["start-lambda"], self.scratch_dir, **config_values
- ) as config_path, tempfile.NamedTemporaryFile() as key_file, tempfile.NamedTemporaryFile() as cert_file:
+ with (
+ samconfig_parameters(["start-lambda"], self.scratch_dir, **config_values) as config_path,
+ tempfile.NamedTemporaryFile() as key_file,
+ tempfile.NamedTemporaryFile() as cert_file,
+ ):
from samcli.commands.local.start_lambda.cli import cli
LOG.debug(Path(config_path).read_text())
tests/unit/lib/build_module/test_build_strategy.py~L747
def test_will_call_incremental_build_strategy(self, mocked_read, mocked_write, runtime):
build_definition = FunctionBuildDefinition(runtime, "codeuri", None, "package_type", X86_64, {}, "handler")
self.build_graph.put_function_build_definition(build_definition, Mock(full_path="function_full_path"))
- with patch.object(
- self.build_strategy, "_incremental_build_strategy"
- ) as patched_incremental_build_strategy, patch.object(
- self.build_strategy, "_cached_build_strategy"
- ) as patched_cached_build_strategy:
+ with (
+ patch.object(self.build_strategy, "_incremental_build_strategy") as patched_incremental_build_strategy,
+ patch.object(self.build_strategy, "_cached_build_strategy") as patched_cached_build_strategy,
+ ):
self.build_strategy.build()
patched_incremental_build_strategy.build_single_function_definition.assert_called_with(build_definition)
tests/unit/lib/build_module/test_build_strategy.py~L767
def test_will_call_cached_build_strategy(self, mocked_read, mocked_write, runtime):
build_definition = FunctionBuildDefinition(runtime, "codeuri", None, "package_type", X86_64, {}, "handler")
self.build_graph.put_function_build_definition(build_definition, Mock(full_path="function_full_path"))
- with patch.object(
- self.build_strategy, "_incremental_build_strategy"
- ) as patched_incremental_build_strategy, patch.object(
- self.build_strategy, "_cached_build_strategy"
- ) as patched_cached_build_strategy:
+ with (
+ patch.object(self.build_strategy, "_incremental_build_strategy") as patched_incremental_build_strategy,
+ patch.object(self.build_strategy, "_cached_build_strategy") as patched_cached_build_strategy,
+ ):
self.build_strategy.build()
patched_cached_build_strategy.build_single_function_definition.assert_called_with(build_definition)
tests/unit/lib/build_module/test_build_strategy.py~L841
build_definition = FunctionBuildDefinition(runtime, "codeuri", None, "package_type", X86_64, {}, "handler")
self.build_graph.put_function_build_definition(build_definition, Mock(full_path="function_full_path"))
- with patch.object(
- build_strategy, "_incremental_build_strategy"
- ) as patched_incremental_build_strategy, patch.object(
- build_strategy, "_cached_build_strategy"
- ) as patched_cached_build_strategy:
+ with (
+ patch.object(build_strategy, "_incremental_build_strategy") as patched_incremental_build_strategy,
+ patch.object(build_strategy, "_cached_build_strategy") as patched_cached_build_strategy,
+ ):
build_strategy.build()
if not use_container:
tests/unit/lib/remote_invoke/test_remote_invoke_executors.py~L79
given_output_format = "text"
test_execution_info = RemoteInvokeExecutionInfo(given_payload, None, given_parameters, given_output_format)
- with patch.object(self.boto_action_executor, "_execute_action") as patched_execute_action, patch.object(
- self.boto_action_executor, "_execute_action_file"
- ) as patched_execute_action_file:
+ with (
+ patch.object(self.boto_action_executor, "_execute_action") as patched_execute_action,
+ patch.object(self.boto_action_executor, "_execute_action_file") as patched_execute_action_file,
+ ):
given_result = Mock()
patched_execute_action.return_value = given_result
tests/unit/lib/remote_invoke/test_remote_invoke_executors.py~L96
given_output_format = "json"
test_execution_info = RemoteInvokeExecutionInfo(None, given_payload_file, given_parameters, given_output_format)
- with patch.object(self.boto_action_executor, "_execute_action") as patched_execute_action, patch.object(
- self.boto_action_executor, "_execute_action_file"
- ) as patched_execute_action_file:
+ with (
+ patch.object(self.boto_action_executor, "_execute_action") as patched_execute_action,
+ patch.object(self.boto_action_executor, "_execute_action_file") as patched_execute_action_file,
+ ):
given_result = Mock()
patched_execute_action_file.return_value = given_result
langchain-ai/langchain (+32 -23 lines across 5 files)
libs/community/tests/unit_tests/document_loaders/test_mongodb.py~L50
mock_collection.find = mock_find
mock_collection.count_documents = mock_count_documents
- with patch(
- "motor.motor_asyncio.AsyncIOMotorClient", return_value=MagicMock()
- ), patch(
- "langchain_community.document_loaders.mongodb.MongodbLoader.aload",
- new=mock_async_load,
+ with (
+ patch("motor.motor_asyncio.AsyncIOMotorClient", return_value=MagicMock()),
+ patch(
+ "langchain_community.document_loaders.mongodb.MongodbLoader.aload",
+ new=mock_async_load,
+ ),
):
loader = MongodbLoader(
"mongodb://localhost:27017",
libs/community/tests/unit_tests/tools/audio/test_tools.py~L44
def test_huggingface_tts_run_with_requests_mock() -> None:
os.environ["HUGGINGFACE_API_KEY"] = "foo"
- with tempfile.TemporaryDirectory() as tmp_dir, patch(
- "uuid.uuid4"
- ) as mock_uuid, patch("requests.post") as mock_inference, patch(
- "builtins.open", mock_open()
- ) as mock_file:
+ with (
+ tempfile.TemporaryDirectory() as tmp_dir,
+ patch("uuid.uuid4") as mock_uuid,
+ patch("requests.post") as mock_inference,
+ patch("builtins.open", mock_open()) as mock_file,
+ ):
input_query = "Dummy input"
mock_uuid_value = uuid.UUID("00000000-0000-0000-0000-000000000000")
libs/community/tests/unit_tests/vectorstores/test_azure_search.py~L220
]
ids_provided = [i.metadata.get("id") for i in documents]
- with patch.object(
- SearchClient, "upload_documents", mock_upload_documents
- ), patch.object(SearchIndexClient, "get_index", mock_default_index):
+ with (
+ patch.object(SearchClient, "upload_documents", mock_upload_documents),
+ patch.object(SearchIndexClient, "get_index", mock_default_index),
+ ):
vector_store = create_vector_store()
ids_used_at_upload = vector_store.add_documents(documents, ids=ids_provided)
assert len(ids_provided) == len(ids_used_at_upload)
libs/langchain/tests/unit_tests/smith/evaluation/test_runner_utils.py~L316
proj.id = "123"
return proj
- with mock.patch.object(
- Client, "read_dataset", new=mock_read_dataset
- ), mock.patch.object(Client, "list_examples", new=mock_list_examples), mock.patch(
- "langchain.smith.evaluation.runner_utils._arun_llm_or_chain",
- new=mock_arun_chain,
- ), mock.patch.object(Client, "create_project", new=mock_create_project):
+ with (
+ mock.patch.object(Client, "read_dataset", new=mock_read_dataset),
+ mock.patch.object(Client, "list_examples", new=mock_list_examples),
+ mock.patch(
+ "langchain.smith.evaluation.runner_utils._arun_llm_or_chain",
+ new=mock_arun_chain,
+ ),
+ mock.patch.object(Client, "create_project", new=mock_create_project),
+ ):
client = Client(api_url="http://localhost:1984", api_key="123")
chain = mock.MagicMock()
chain.input_keys = ["foothing"]
libs/partners/huggingface/tests/unit_tests/test_chat_models.py~L231
def test_bind_tools(chat_hugging_face: Any) -> None:
tools = [MagicMock(spec=BaseTool)]
- with patch(
- "langchain_huggingface.chat_models.huggingface.convert_to_openai_tool",
- side_effect=lambda x: x,
- ), patch("langchain_core.runnables.base.Runnable.bind") as mock_super_bind:
+ with (
+ patch(
+ "langchain_huggingface.chat_models.huggingface.convert_to_openai_tool",
+ side_effect=lambda x: x,
+ ),
+ patch("langchain_core.runnables.base.Runnable.bind") as mock_super_bind,
+ ):
chat_hugging_face.bind_tools(tools, tool_choice="auto")
mock_super_bind.assert_called_once()
_, kwargs = mock_super_bind.call_args
prefecthq/prefect (+38 -27 lines across 5 files)
src/integrations/prefect-dbt/prefect_dbt/cloud/jobs.py~L752
run_status = DbtCloudJobRunStatus(run_data.get("status"))
if run_status == DbtCloudJobRunStatus.SUCCESS:
try:
- async with self._dbt_cloud_credentials.get_administrative_client() as client: # noqa
+ async with (
+ self._dbt_cloud_credentials.get_administrative_client() as client
+ ): # noqa
response = await client.list_run_artifacts(
run_id=self.run_id, step=step
)
tests/runner/test_webserver.py~L151
webserver = await build_server(runner)
client = TestClient(webserver)
- with mock.patch(
- "prefect.runner.server.get_client", new=mock_get_client
- ), mock.patch.object(runner, "execute_in_background"):
+ with (
+ mock.patch("prefect.runner.server.get_client", new=mock_get_client),
+ mock.patch.object(runner, "execute_in_background"),
+ ):
with client:
response = client.post(f"/deployment/{deployment_id}/run")
assert response.status_code == 201, response.json()
tests/server/orchestration/api/test_task_run_subscriptions.py~L326
)
await queue.put(task_run)
- with patch("asyncio.sleep", return_value=None), pytest.raises(
- asyncio.TimeoutError
+ with (
+ patch("asyncio.sleep", return_value=None),
+ pytest.raises(asyncio.TimeoutError),
):
extra_task_run = ServerTaskRun(
id=uuid4(),
tests/server/orchestration/api/test_task_run_subscriptions.py~L356
)
await queue.retry(task_run)
- with patch("asyncio.sleep", return_value=None), pytest.raises(
- asyncio.TimeoutError
+ with (
+ patch("asyncio.sleep", return_value=None),
+ pytest.raises(asyncio.TimeoutError),
):
extra_task_run = ServerTaskRun(
id=uuid4(),
tests/test_task_worker.py~L106
async def test_handle_sigterm(mock_create_subscription):
task_worker = TaskWorker(...)
- with patch("sys.exit") as mock_exit, patch.object(
- task_worker, "stop", new_callable=AsyncMock
- ) as mock_stop:
+ with (
+ patch("sys.exit") as mock_exit,
+ patch.object(task_worker, "stop", new_callable=AsyncMock) as mock_stop,
+ ):
await task_worker.start()
mock_create_subscription.assert_called_once()
tests/test_task_worker.py~L120
async def test_task_worker_client_id_is_set():
- with patch("socket.gethostname", return_value="foo"), patch(
- "os.getpid", return_value=42
+ with (
+ patch("socket.gethostname", return_value="foo"),
+ patch("os.getpid", return_value=42),
):
task_worker = TaskWorker(...)
task_worker._client = MagicMock(api_url="http://localhost:4200")
tests/workers/test_base_worker.py~L1985
):
async with WorkerTestImpl(work_pool_name=work_pool.name) as worker:
await worker.start(run_once=True)
- with mock.patch(
- "prefect....*[Comment body truncated]*
The UP027 removal means that we now error on |
Since we are stabilizing things, there seem to be many lower risk FURB rules we could stabilize: https://docs.astral.sh/ruff/rules/#refurb-furb like FURB148, FURB131, FURB145 |
Thanks @Skylion007. I'll be spending a bunch of time this week looking through which rules are suitable for stabilisation in this release. I'll make sure to look at those, among many others :-) |
Btw I got a relevant feature request to make those warnings by default: #13505 (so that configs can work across more versions without failing) |
CodSpeed Performance ReportMerging #14383 will improve performances by 4.44%Comparing Summary
Benchmarks breakdown
|
10c6a2a
to
5532cc0
Compare
2d79184
to
f0cdc24
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
…14401) This PR stabilizes the unsafe fix for [zip-instead-of-pairwise (RUF007)](https://docs.astral.sh/ruff/rules/zip-instead-of-pairwise/#zip-instead-of-pairwise-ruf007), which replaces the use of zip with that of itertools.pairwise and has been available under preview since version 0.5.7. There are no open issues regarding RUF007 at the time of this writing.
…le in `printf-string-formatting (UP031)` (#14406)
Co-authored-by: Micha Reiser <micha@reiser.io>
…-variable-name (E741)` (#14405)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…ANN102 (#14384) Co-authored-by: Micha Reiser <micha@reiser.io>
…PT005 (#14385) Co-authored-by: Micha Reiser <micha@reiser.io>
Needed to prevent updater failures when doing #13927 See - axodotdev/axoupdater#210 - axodotdev/cargo-dist#1538 - astral-sh/uv#8958
…der-slots` (#14468) ## Summary These rules were implemented in January, have been very stable, and have no open issues about them. They were highly requested by the community prior to being implemented. Let's stabilise them! ## Test Plan Ecosystem check on this PR.
## Summary - Expand some docs where they're unclear about the motivation, or assume some knowledge that hasn't been introduced yet - Add more links to external docs - Rename PYI063 from `PrePep570PositionalArgument` to `Pep484StylePositionalOnlyParameter` - Rename the file `parenthesize_logical_operators.rs` to `parenthesize_chained_operators.rs`, since the rule is called `ParenthesizeChainedOperators`, not `ParenthesizeLogicalOperators` ## Test Plan `cargo test`
4f95abf
to
b61eda2
Compare
Ah, the FURB rules didn't make it? ;-; |
Not this release, unfortunately. I did look at them, but I'm a little concerned that these rules are quite highly opinionated. I'm not sure all users would agree that the changes they recommend would result in more idiomatic Python; I think they're very subjective. The long-term answer to this problem is to improve our rule categorisation so that we can clearly signal to users that these are highly opinionated rules and have them disabled by default. Unfortunately I can't tell you when rule recategorisation is likely to happen, however :-( |
@AlexWaygood I agree with most of the FURB rules being opinionated, but my understanding is that FURB131, FURB132, and FURB145 have performance implications in code which is why I wanted to enable those specifically. FURB148 also just removes an unused variable/functional call, but I can see why that might want to be left in preview because the fixit is more complicated. |
It's possible that some of these might make a tiny difference to performance, but I think it's very unlikely to make a significant difference unless you're in a very hot loop. The recommendations to avoid slicing are also the kind of thing where relative performance of different idioms is likely to change quite a lot between Python releases (especially right now, when there's a lot of work going into Python performance, and when very significant optimisations for slices have just been landed on the CPython |
Summary
ruff
] Stabilize unsafe fix forzip-instead-of-pairwise (RUF007)
#14401pyupgrade
] Stabilize behavior to show diagnostic even when unfixable inprintf-string-formatting (UP031)
#14406pycodestyle
] Stabilize behavior to ignore stub files inambiguous-variable-name (E741)
#14405flake8-type-checking
] RenameTCH
toTC
#14438flake8-annotations
] Remove deprecated rules ANN101 and ANN102 #14384flake8-pytest-style
] Remove deprecated rules PT004 and PT005 #14385E999
rule code #14428ruff
] Stabiliseparenthesize-chained-operators
(RUF021
) #14450~/.local/bin
) instead of the Cargo home directory in the installer #14457ruff
] Stabiliseunsorted-dunder-all
andunsorted-dunder-slots
#14468A004
#14480Test Plan
cargo test