-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add a formatter CLI for debugging #4809
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
PR Check ResultsEcosystemℹ️ ecosystem check detected changes. (+10, -10, 0 error(s)) airflow (+10, -10)
+ airflow/settings.py:63:10: FLY002 [*] Consider `" ____________ _____________\n ____ |__( )_________ __/__ /________ __\n____ /| |_ /__ ___/_ /_ __ /_ __ \\_ | /| / /\n___ ___ | / _ / _ __/ _ / / /_/ /_ |/ |/ /\n _/_/ |_/_/ /_/ /_/ /_/ \\____/____/|__/"` instead of string join
- airflow/settings.py:63:10: FLY002 [*] Consider `f" ____________ _____________\n ____ |__( )_________ __/__ /________ __\n____ /| |_ /__ ___/_ /_ __ /_ __ \\_ | /| / /\n___ ___ | / _ / _ __/ _ / / /_/ /_ |/ |/ /\n _/_/ |_/_/ /_/ /_/ /_/ \\____/____/|__/"` instead of string join
+ tests/cli/commands/test_kubernetes_command.py:60:22: FLY002 [*] Consider `"dag_id,task_id,try_number,airflow_version"` instead of string join
- tests/cli/commands/test_kubernetes_command.py:60:22: FLY002 [*] Consider `f"dag_id,task_id,try_number,airflow_version"` instead of string join
+ tests/providers/google/common/hooks/test_base_google.py:527:17: FLY002 [*] Consider `"https://www.googleapis.com/auth/bigquery,https://www.googleapis.com/auth/devstorage.read_only"` instead of string join
- tests/providers/google/common/hooks/test_base_google.py:527:17: FLY002 [*] Consider `f"https://www.googleapis.com/auth/bigquery,https://www.googleapis.com/auth/devstorage.read_only"` instead of string join
+ tests/providers/google/common/hooks/test_base_google.py:594:17: FLY002 [*] Consider `"https://www.googleapis.com/auth/bigquery,https://www.googleapis.com/auth/devstorage.read_only"` instead of string join
- tests/providers/google/common/hooks/test_base_google.py:594:17: FLY002 [*] Consider `f"https://www.googleapis.com/auth/bigquery,https://www.googleapis.com/auth/devstorage.read_only"` instead of string join
+ tests/utils/test_dot_renderer.py:181:38: FLY002 [*] Consider `'digraph example_task_group {\n\tgraph [label=example_task_group labelloc=t rankdir=LR]\n\tend [color="#000000" fillcolor="#e8f7e4" label=end shape=rectangle style="filled,rounded"]\n\tsubgraph cluster_section_1 {\n\t\tcolor="#000000" fillcolor="#6495ed7f" label=section_1 shape=rectangle style=filled\n\t\t"section_1.upstream_join_id" [color="#000000" fillcolor=CornflowerBlue height=0.2 label="" shape=circle style="filled,rounded" width=0.2]\n\t\t"section_1.downstream_join_id" [color="#000000" fillcolor=CornflowerBlue height=0.2 label="" shape=circle style="filled,rounded" width=0.2]\n\t\t"section_1.task_1" [color="#000000" fillcolor="#e8f7e4" label=task_1 shape=rectangle style="filled,rounded"]\n\t\t"section_1.task_2" [color="#000000" fillcolor="#f0ede4" label=task_2 shape=rectangle style="filled,rounded"]\n\t\t"section_1.task_3" [color="#000000" fillcolor="#e8f7e4" label=task_3 shape=rectangle style="filled,rounded"]\n\t}\n\tsubgraph cluster_section_2 {\n\t\tcolor="#000000" fillcolor="#6495ed7f" label=section_2 shape=rectangle style=filled\n\t\t"section_2.upstream_join_id" [color="#000000" fillcolor=CornflowerBlue height=0.2 label="" shape=circle style="filled,rounded" width=0.2]\n\t\t"section_2.downstream_join_id" [color="#000000" fillcolor=CornflowerBlue height=0.2 label="" shape=circle style="filled,rounded" width=0.2]\n\t\tsubgraph "cluster_section_2.inner_section_2" {\n\t\t\tcolor="#000000" fillcolor="#6495ed7f" label=inner_section_2 shape=rectangle style=filled\n\t\t\t"section_2.inner_section_2.task_2" [color="#000000" fillcolor="#f0ede4" label=task_2 shape=rectangle style="filled,rounded"]\n\t\t\t"section_2.inner_section_2.task_3" [color="#000000" fillcolor="#e8f7e4" label=task_3 shape=rectangle style="filled,rounded"]\n\t\t\t"section_2.inner_section_2.task_4" [color="#000000" fillcolor="#e8f7e4" label=task_4 shape=rectangle style="filled,rounded"]\n\t\t}\n\t\t"section_2.task_1" [color="#000000" fillcolor="#e8f7e4" label=task_1 shape=rectangle style="filled,rounded"]\n\t}\n\tstart [color="#000000" fillcolor="#e8f7e4" label=start shape=rectangle style="filled,rounded"]\n\t"section_1.downstream_join_id" -> "section_2.upstream_join_id"\n\t"section_1.task_1" -> "section_1.task_2"\n\t"section_1.task_1" -> "section_1.task_3"\n\t"section_1.task_2" -> "section_1.downstream_join_id"\n\t"section_1.task_3" -> "section_1.downstream_join_id"\n\t"section_1.upstream_join_id" -> "section_1.task_1"\n\t"section_2.downstream_join_id" -> end\n\t"section_2.inner_section_2.task_2" -> "section_2.inner_section_2.task_4"\n\t"section_2.inner_section_2.task_3" -> "section_2.inner_section_2.task_4"\n\t"section_2.inner_section_2.task_4" -> "section_2.downstream_join_id"\n\t"section_2.task_1" -> "section_2.downstream_join_id"\n\t"section_2.upstream_join_id" -> "section_2.inner_section_2.task_2"\n\t"section_2.upstream_join_id" -> "section_2.inner_section_2.task_3"\n\t"section_2.upstream_join_id" -> "section_2.task_1"\n\tstart -> "section_1.upstream_join_id"\n}'` instead of string join
- tests/utils/test_dot_renderer.py:181:38: FLY002 [*] Consider `f'digraph example_task_group {{\n\tgraph [label=example_task_group labelloc=t rankdir=LR]\n\tend [color="#000000" fillcolor="#e8f7e4" label=end shape=rectangle style="filled,rounded"]\n\tsubgraph cluster_section_1 {{\n\t\tcolor="#000000" fillcolor="#6495ed7f" label=section_1 shape=rectangle style=filled\n\t\t"section_1.upstream_join_id" [color="#000000" fillcolor=CornflowerBlue height=0.2 label="" shape=circle style="filled,rounded" width=0.2]\n\t\t"section_1.downstream_join_id" [color="#000000" fillcolor=CornflowerBlue height=0.2 label="" shape=circle style="filled,rounded" width=0.2]\n\t\t"section_1.task_1" [color="#000000" fillcolor="#e8f7e4" label=task_1 shape=rectangle style="filled,rounded"]\n\t\t"section_1.task_2" [color="#000000" fillcolor="#f0ede4" label=task_2 shape=rectangle style="filled,rounded"]\n\t\t"section_1.task_3" [color="#000000" fillcolor="#e8f7e4" label=task_3 shape=rectangle style="filled,rounded"]\n\t}}\n\tsubgraph cluster_section_2 {{\n\t\tcolor="#000000" fillcolor="#6495ed7f" label=section_2 shape=rectangle style=filled\n\t\t"section_2.upstream_join_id" [color="#000000" fillcolor=CornflowerBlue height=0.2 label="" shape=circle style="filled,rounded" width=0.2]\n\t\t"section_2.downstream_join_id" [color="#000000" fillcolor=CornflowerBlue height=0.2 label="" shape=circle style="filled,rounded" width=0.2]\n\t\tsubgraph "cluster_section_2.inner_section_2" {{\n\t\t\tcolor="#000000" fillcolor="#6495ed7f" label=inner_section_2 shape=rectangle style=filled\n\t\t\t"section_2.inner_section_2.task_2" [color="#000000" fillcolor="#f0ede4" label=task_2 shape=rectangle style="filled,rounded"]\n\t\t\t"section_2.inner_section_2.task_3" [color="#000000" fillcolor="#e8f7e4" label=task_3 shape=rectangle style="filled,rounded"]\n\t\t\t"section_2.inner_section_2.task_4" [color="#000000" fillcolor="#e8f7e4" label=task_4 shape=rectangle style="filled,rounded"]\n\t\t}}\n\t\t"section_2.task_1" [color="#000000" fillcolor="#e8f7e4" label=task_1 shape=rectangle style="filled,rounded"]\n\t}}\n\tstart [color="#000000" fillcolor="#e8f7e4" label=start shape=rectangle style="filled,rounded"]\n\t"section_1.downstream_join_id" -> "section_2.upstream_join_id"\n\t"section_1.task_1" -> "section_1.task_2"\n\t"section_1.task_1" -> "section_1.task_3"\n\t"section_1.task_2" -> "section_1.downstream_join_id"\n\t"section_1.task_3" -> "section_1.downstream_join_id"\n\t"section_1.upstream_join_id" -> "section_1.task_1"\n\t"section_2.downstream_join_id" -> end\n\t"section_2.inner_section_2.task_2" -> "section_2.inner_section_2.task_4"\n\t"section_2.inner_section_2.task_3" -> "section_2.inner_section_2.task_4"\n\t"section_2.inner_section_2.task_4" -> "section_2.downstream_join_id"\n\t"section_2.task_1" -> "section_2.downstream_join_id"\n\t"section_2.upstream_join_id" -> "section_2.inner_section_2.task_2"\n\t"section_2.upstream_join_id" -> "section_2.inner_section_2.task_3"\n\t"section_2.upstream_join_id" -> "section_2.task_1"\n\tstart -> "section_1.upstream_join_id"\n}}'` instead of string join
+ tests/utils/test_log_handlers.py:414:13: FLY002 [*] Consider `"airflow_version=.+?,dag_id=dag_for_testing_file_task_handler,kubernetes_executor=True,run_id=manual__2016-01-01T0000000000-2b88d1d57,task_id=task_for_testing_file_log_handler,try_number=2,airflow-worker"` instead of string join
- tests/utils/test_log_handlers.py:414:13: FLY002 [*] Consider `f"airflow_version=.+?,dag_id=dag_for_testing_file_task_handler,kubernetes_executor=True,run_id=manual__2016-01-01T0000000000-2b88d1d57,task_id=task_for_testing_file_log_handler,try_number=2,airflow-worker"` instead of string join
+ tests/utils/test_log_handlers.py:589:19: FLY002 [*] Consider `"[2022-11-16T00:05:54.278-0800] {taskinstance.py:1258} INFO - Starting attempt 1 of 1"` instead of string join
- tests/utils/test_log_handlers.py:589:19: FLY002 [*] Consider `f"[2022-11-16T00:05:54.278-0800] {{taskinstance.py:1258}} INFO - Starting attempt 1 of 1"` instead of string join
+ tests/utils/test_log_handlers.py:594:19: FLY002 [*] Consider `"[2022-11-16T00:05:54.295-0800] {taskinstance.py:1278} INFO - Executing <Task(TimeDeltaSensorAsync): wait> on 2022-11-16 08:05:52.324532+00:00\n[2022-11-16T00:05:54.300-0800] {standard_task_runner.py:55} INFO - Started process 52536 to run task\n[2022-11-16T00:05:54.300-0800] {standard_task_runner.py:55} INFO - Started process 52536 to run task\n[2022-11-16T00:05:54.300-0800] {standard_task_runner.py:55} INFO - Started process 52536 to run task\n[2022-11-16T00:05:54.306-0800] {standard_task_runner.py:82} INFO - Running: ['airflow', 'tasks', 'run', 'simple_async_timedelta', 'wait', 'manual__2022-11-16T08:05:52.324532+00:00', '--job-id', '33648', '--raw', '--subdir', '/Users/dstandish/code/airflow/airflow/example_dags/example_time_delta_sensor_async.py', '--cfg-path', '/var/folders/7_/1xx0hqcs3txd7kqt0ngfdjth0000gn/T/tmp725r305n']\n[2022-11-16T00:05:54.309-0800] {standard_task_runner.py:83} INFO - Job 33648: Subtask wait"` instead of string join
- tests/utils/test_log_handlers.py:594:19: FLY002 [*] Consider `f"[2022-11-16T00:05:54.295-0800] {{taskinstance.py:1278}} INFO - Executing <Task(TimeDeltaSensorAsync): wait> on 2022-11-16 08:05:52.324532+00:00\n[2022-11-16T00:05:54.300-0800] {{standard_task_runner.py:55}} INFO - Started process 52536 to run task\n[2022-11-16T00:05:54.300-0800] {{standard_task_runner.py:55}} INFO - Started process 52536 to run task\n[2022-11-16T00:05:54.300-0800] {{standard_task_runner.py:55}} INFO - Started process 52536 to run task\n[2022-11-16T00:05:54.306-0800] {{standard_task_runner.py:82}} INFO - Running: ['airflow', 'tasks', 'run', 'simple_async_timedelta', 'wait', 'manual__2022-11-16T08:05:52.324532+00:00', '--job-id', '33648', '--raw', '--subdir', '/Users/dstandish/code/airflow/airflow/example_dags/example_time_delta_sensor_async.py', '--cfg-path', '/var/folders/7_/1xx0hqcs3txd7kqt0ngfdjth0000gn/T/tmp725r305n']\n[2022-11-16T00:05:54.309-0800] {{standard_task_runner.py:83}} INFO - Job 33648: Subtask wait"` instead of string join
+ tests/utils/test_log_handlers.py:604:19: FLY002 [*] Consider `"[2022-11-16T00:05:54.457-0800] {task_command.py:376} INFO - Running <TaskInstance: simple_async_timedelta.wait manual__2022-11-16T08:05:52.324532+00:00 [running]> on host daniels-mbp-2.lan\n[2022-11-16T00:05:54.592-0800] {taskinstance.py:1485} INFO - Exporting env vars: AIRFLOW_CTX_DAG_OWNER=airflow\nAIRFLOW_CTX_DAG_ID=simple_async_timedelta\nAIRFLOW_CTX_TASK_ID=wait\nAIRFLOW_CTX_EXECUTION_DATE=2022-11-16T08:05:52.324532+00:00\nAIRFLOW_CTX_TRY_NUMBER=1\nAIRFLOW_CTX_DAG_RUN_ID=manual__2022-11-16T08:05:52.324532+00:00\n[2022-11-16T00:05:54.604-0800] {taskinstance.py:1360} INFO - Pausing task as DEFERRED. dag_id=simple_async_timedelta, task_id=wait, execution_date=20221116T080552, start_date=20221116T080554"` instead of string join
- tests/utils/test_log_handlers.py:604:19: FLY002 [*] Consider `f"[2022-11-16T00:05:54.457-0800] {{task_command.py:376}} INFO - Running <TaskInstance: simple_async_timedelta.wait manual__2022-11-16T08:05:52.324532+00:00 [running]> on host daniels-mbp-2.lan\n[2022-11-16T00:05:54.592-0800] {{taskinstance.py:1485}} INFO - Exporting env vars: AIRFLOW_CTX_DAG_OWNER=airflow\nAIRFLOW_CTX_DAG_ID=simple_async_timedelta\nAIRFLOW_CTX_TASK_ID=wait\nAIRFLOW_CTX_EXECUTION_DATE=2022-11-16T08:05:52.324532+00:00\nAIRFLOW_CTX_TRY_NUMBER=1\nAIRFLOW_CTX_DAG_RUN_ID=manual__2022-11-16T08:05:52.324532+00:00\n[2022-11-16T00:05:54.604-0800] {{taskinstance.py:1360}} INFO - Pausing task as DEFERRED. dag_id=simple_async_timedelta, task_id=wait, execution_date=20221116T080552, start_date=20221116T080554"` instead of string join
+ tests/utils/test_log_handlers.py:616:16: FLY002 [*] Consider `"[2022-11-16T00:05:54.278-0800] {taskinstance.py:1258} INFO - Starting attempt 1 of 1\n[2022-11-16T00:05:54.295-0800] {taskinstance.py:1278} INFO - Executing <Task(TimeDeltaSensorAsync): wait> on 2022-11-16 08:05:52.324532+00:00\n[2022-11-16T00:05:54.300-0800] {standard_task_runner.py:55} INFO - Started process 52536 to run task\n[2022-11-16T00:05:54.306-0800] {standard_task_runner.py:82} INFO - Running: ['airflow', 'tasks', 'run', 'simple_async_timedelta', 'wait', 'manual__2022-11-16T08:05:52.324532+00:00', '--job-id', '33648', '--raw', '--subdir', '/Users/dstandish/code/airflow/airflow/example_dags/example_time_delta_sensor_async.py', '--cfg-path', '/var/folders/7_/1xx0hqcs3txd7kqt0ngfdjth0000gn/T/tmp725r305n']\n[2022-11-16T00:05:54.309-0800] {standard_task_runner.py:83} INFO - Job 33648: Subtask wait\n[2022-11-16T00:05:54.457-0800] {task_command.py:376} INFO - Running <TaskInstance: simple_async_timedelta.wait manual__2022-11-16T08:05:52.324532+00:00 [running]> on host daniels-mbp-2.lan\n[2022-11-16T00:05:54.592-0800] {taskinstance.py:1485} INFO - Exporting env vars: AIRFLOW_CTX_DAG_OWNER=airflow\nAIRFLOW_CTX_DAG_ID=simple_async_timedelta\nAIRFLOW_CTX_TASK_ID=wait\nAIRFLOW_CTX_EXECUTION_DATE=2022-11-16T08:05:52.324532+00:00\nAIRFLOW_CTX_TRY_NUMBER=1\nAIRFLOW_CTX_DAG_RUN_ID=manual__2022-11-16T08:05:52.324532+00:00\n[2022-11-16T00:05:54.604-0800] {taskinstance.py:1360} INFO - Pausing task as DEFERRED. dag_id=simple_async_timedelta, task_id=wait, execution_date=20221116T080552, start_date=20221116T080554"` instead of string join
- tests/utils/test_log_handlers.py:616:16: FLY002 [*] Consider `f"[2022-11-16T00:05:54.278-0800] {{taskinstance.py:1258}} INFO - Starting attempt 1 of 1\n[2022-11-16T00:05:54.295-0800] {{taskinstance.py:1278}} INFO - Executing <Task(TimeDeltaSensorAsync): wait> on 2022-11-16 08:05:52.324532+00:00\n[2022-11-16T00:05:54.300-0800] {{standard_task_runner.py:55}} INFO - Started process 52536 to run task\n[2022-11-16T00:05:54.306-0800] {{standard_task_runner.py:82}} INFO - Running: ['airflow', 'tasks', 'run', 'simple_async_timedelta', 'wait', 'manual__2022-11-16T08:05:52.324532+00:00', '--job-id', '33648', '--raw', '--subdir', '/Users/dstandish/code/airflow/airflow/example_dags/example_time_delta_sensor_async.py', '--cfg-path', '/var/folders/7_/1xx0hqcs3txd7kqt0ngfdjth0000gn/T/tmp725r305n']\n[2022-11-16T00:05:54.309-0800] {{standard_task_runner.py:83}} INFO - Job 33648: Subtask wait\n[2022-11-16T00:05:54.457-0800] {{task_command.py:376}} INFO - Running <TaskInstance: simple_async_timedelta.wait manual__2022-11-16T08:05:52.324532+00:00 [running]> on host daniels-mbp-2.lan\n[2022-11-16T00:05:54.592-0800] {{taskinstance.py:1485}} INFO - Exporting env vars: AIRFLOW_CTX_DAG_OWNER=airflow\nAIRFLOW_CTX_DAG_ID=simple_async_timedelta\nAIRFLOW_CTX_TASK_ID=wait\nAIRFLOW_CTX_EXECUTION_DATE=2022-11-16T08:05:52.324532+00:00\nAIRFLOW_CTX_TRY_NUMBER=1\nAIRFLOW_CTX_DAG_RUN_ID=manual__2022-11-16T08:05:52.324532+00:00\n[2022-11-16T00:05:54.604-0800] {{taskinstance.py:1360}} INFO - Pausing task as DEFERRED. dag_id=simple_async_timedelta, task_id=wait, execution_date=20221116T080552, start_date=20221116T080554"` instead of string join
BenchmarkLinux
Windows
|
format!("Could not write to {}, exiting", file.display()) | ||
})?; | ||
} | ||
} |
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.
Wishlist (for follow up PR if you're interested)
--print-ir
: Prints theformatted.document().display()
instead of or in addition to writing the file--print-comments
: Printsformatted.context().comments().debug()
insteadof or in addition to writting the file
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.
to we want to print that to file or only to stdout?
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.
Stdout is fine for me.
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.
Done: cargo run --bin ruff_python_formatter -- --print-ir --print-comments scratch.py
This adds a ruff_python_formatter cli modelled aber `rustfmt` that i use for debugging
Tested with `cargo run --bin ruff_python_formatter -- --print-ir --print-comments scratch.py`
Move this branch off the other so we can merge it first |
* Add a formatter CLI for debugging This adds a ruff_python_formatter cli modelled aber `rustfmt` that i use for debugging * clippy * Add print IR and print comments options Tested with `cargo run --bin ruff_python_formatter -- --print-ir --print-comments scratch.py`
Summary
This add a
ruff_python_formatter
cli modeled afterrustfmt
that i use to test my changes.Test Plan
It's a debugging tool, as which it worked for me