Skip to content

Commit fefce37

Browse files
jschefflephraimbuddy
authored andcommitted
[v3-1-test] Enable ruff PLW1510 rule (#57660) (#57674)
* Enable ruff PLW1510 rule * Exclude prek check for run_command (cherry picked from commit a79d8db)
1 parent 2792668 commit fefce37

14 files changed

Lines changed: 34 additions & 15 deletions

File tree

airflow-core/tests/unit/charts/helm_template_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def render_chart(
141141
if show_only:
142142
for i in show_only:
143143
command.extend(["--show-only", i])
144-
result = subprocess.run(command, capture_output=True, cwd=chart_dir)
144+
result = subprocess.run(command, check=False, capture_output=True, cwd=chart_dir)
145145
if result.returncode:
146146
raise HelmFailedError(result.returncode, result.args, result.stdout, result.stderr)
147147
templates = result.stdout

dev/breeze/src/airflow_breeze/utils/publish_docs_to_s3.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ def sync_docs_to_s3(self, source: str, destination: str):
123123
return (0, "")
124124
get_console().print(f"[info]Syncing {source} to {destination}\n")
125125
result = subprocess.run(
126-
["aws", "s3", "sync", "--delete", source, destination], capture_output=True, text=True
126+
["aws", "s3", "sync", "--delete", source, destination],
127+
check=False,
128+
capture_output=True,
129+
text=True,
127130
)
128131
return (result.returncode, result.stderr)
129132

devel-common/src/sphinx_exts/docs_build/docs_builder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def check_spelling(self, verbose: bool) -> tuple[list[SpellingError], list[DocBu
192192
with open(self.log_spelling_filename, "w") as output:
193193
completed_proc = run(
194194
build_cmd,
195+
check=False,
195196
cwd=AIRFLOW_CONTENT_ROOT_PATH,
196197
env=env,
197198
stdout=output if not verbose else None,
@@ -274,6 +275,7 @@ def build_sphinx_docs(self, verbose: bool) -> list[DocBuildError]:
274275
with open(self.log_build_filename, "w") as output:
275276
completed_proc = run(
276277
build_cmd,
278+
check=False,
277279
cwd=AIRFLOW_CONTENT_ROOT_PATH,
278280
env=env,
279281
stdout=output if not verbose else None,

helm-tests/tests/chart_utils/helm_template_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def render_chart(
203203
if show_only:
204204
for i in show_only:
205205
command.extend(["--show-only", i])
206-
result = subprocess.run(command, capture_output=True, cwd=chart_dir)
206+
result = subprocess.run(command, check=False, capture_output=True, cwd=chart_dir)
207207
if result.returncode:
208208
raise HelmFailedError(result.returncode, result.args, result.stdout, result.stderr)
209209
templates = result.stdout

providers/amazon/src/airflow/providers/amazon/aws/executors/aws_lambda/docker/app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ def run_and_report(command, task_key):
6666
try:
6767
log.info("Starting execution for task: %s", task_key)
6868
result = subprocess.run(
69-
command, shell=isinstance(command, str), stdout=subprocess.PIPE, stderr=subprocess.STDOUT
69+
command,
70+
check=False,
71+
shell=isinstance(command, str),
72+
stdout=subprocess.PIPE,
73+
stderr=subprocess.STDOUT,
7074
)
7175
return_code = result.returncode
7276
log.info("Execution completed for task %s with return code %s", task_key, return_code)

providers/celery/src/airflow/providers/celery/executors/celery_executor_utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,14 @@ def _execute_in_subprocess(command_to_exec: CommandType, celery_task_id: str | N
247247
if celery_task_id:
248248
env["external_executor_id"] = celery_task_id
249249
try:
250-
subprocess.run(command_to_exec, stderr=sys.__stderr__, stdout=sys.__stdout__, close_fds=True, env=env)
250+
subprocess.run(
251+
command_to_exec,
252+
check=False,
253+
stderr=sys.__stderr__,
254+
stdout=sys.__stdout__,
255+
close_fds=True,
256+
env=env,
257+
)
251258
except subprocess.CalledProcessError as e:
252259
log.exception("[%s] execute_command encountered a CalledProcessError", celery_task_id)
253260
log.error(e.output)

providers/google/src/airflow/providers/google/cloud/hooks/cloud_sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ def _generate_login_token(self, service_account) -> str:
12121212
cloud_sql_hook = CloudSQLHook(api_version="v1", gcp_conn_id=self.gcp_conn_id)
12131213

12141214
with cloud_sql_hook.provide_authorized_gcloud():
1215-
proc = subprocess.run(cmd, capture_output=True)
1215+
proc = subprocess.run(cmd, check=False, capture_output=True)
12161216

12171217
if proc.returncode != 0:
12181218
stderr_last_20_lines = "\n".join(proc.stderr.decode().strip().splitlines()[-20:])

providers/google/src/airflow/providers/google/cloud/hooks/dataflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ def _create_dataflow_job_with_gcloud(self, cmd: list[str]) -> str:
10051005
success_code = 0
10061006

10071007
with self.provide_authorized_gcloud():
1008-
proc = subprocess.run(cmd, capture_output=True)
1008+
proc = subprocess.run(cmd, check=False, capture_output=True)
10091009

10101010
if proc.returncode != success_code:
10111011
stderr_last_20_lines = "\n".join(proc.stderr.decode().strip().splitlines()[-20:])

providers/google/src/airflow/providers/google/cloud/hooks/dataproc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def _create_dataproc_cluster_with_gcloud(self, cmd: list[str]) -> str:
298298
success_code = 0
299299

300300
with self.provide_authorized_gcloud():
301-
proc = subprocess.run(cmd, capture_output=True)
301+
proc = subprocess.run(cmd, check=False, capture_output=True)
302302

303303
if proc.returncode != success_code:
304304
stderr_last_20_lines = "\n".join(proc.stderr.decode().strip().splitlines()[-20:])

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ extend-select = [
601601
"PLW1501", # {mode} is not a valid mode for open
602602
"PLW1507", # Shallow copy of os.environ via copy.copy(os.environ)
603603
"PLW1508", # Invalid type for environment variable default; expected str or None
604+
"PLW1510", # subprocess.run without explicit check argument
604605
# Per rule enables
605606
"RUF006", # Checks for asyncio dangling task
606607
"RUF015", # Checks for unnecessary iterable allocation for first element

0 commit comments

Comments
 (0)