Skip to content
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

Merged
merged 3 commits into from
Jun 5, 2023
Merged

Add a formatter CLI for debugging #4809

merged 3 commits into from
Jun 5, 2023

Conversation

konstin
Copy link
Member

@konstin konstin commented Jun 2, 2023

Summary

This add a ruff_python_formatter cli modeled after rustfmt that i use to test my changes.

Test Plan

It's a debugging tool, as which it worked for me

@konstin
Copy link
Member Author

konstin commented Jun 2, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@konstin konstin added internal An internal refactor or improvement formatter Related to the formatter labels Jun 2, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2023

PR Check Results

Ecosystem

ℹ️ 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

Rules changed: 1
Rule Changes Additions Removals
FLY002 20 10 10

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.00     13.7±0.08ms     3.0 MB/sec    1.08     14.7±0.04ms     2.8 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      3.3±0.01ms     5.0 MB/sec    1.05      3.5±0.00ms     4.8 MB/sec
linter/all-rules/numpy/globals.py          1.00    409.2±1.00µs     7.2 MB/sec    1.04    423.6±0.72µs     7.0 MB/sec
linter/all-rules/pydantic/types.py         1.00      5.8±0.08ms     4.4 MB/sec    1.08      6.2±0.02ms     4.1 MB/sec
linter/default-rules/large/dataset.py      1.00      6.7±0.01ms     6.1 MB/sec    1.14      7.6±0.02ms     5.4 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00   1445.9±2.59µs    11.5 MB/sec    1.10   1586.8±5.22µs    10.5 MB/sec
linter/default-rules/numpy/globals.py      1.00    159.4±0.28µs    18.5 MB/sec    1.06    168.8±0.17µs    17.5 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.0±0.00ms     8.5 MB/sec    1.11      3.3±0.01ms     7.6 MB/sec
parser/large/dataset.py                    1.01      5.3±0.00ms     7.7 MB/sec    1.00      5.2±0.00ms     7.8 MB/sec
parser/numpy/ctypeslib.py                  1.00   1033.3±1.90µs    16.1 MB/sec    1.00   1028.4±4.72µs    16.2 MB/sec
parser/numpy/globals.py                    1.01    108.6±0.17µs    27.2 MB/sec    1.00    107.6±0.59µs    27.4 MB/sec
parser/pydantic/types.py                   1.00      2.3±0.00ms    11.3 MB/sec    1.00      2.3±0.00ms    11.3 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.00     18.8±0.48ms     2.2 MB/sec    1.00     18.7±0.53ms     2.2 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      4.8±0.18ms     3.5 MB/sec    1.00      4.8±0.27ms     3.5 MB/sec
linter/all-rules/numpy/globals.py          1.00   556.0±23.48µs     5.3 MB/sec    1.01   562.8±20.90µs     5.2 MB/sec
linter/all-rules/pydantic/types.py         1.00      7.9±0.25ms     3.2 MB/sec    1.01      8.0±0.37ms     3.2 MB/sec
linter/default-rules/large/dataset.py      1.01      9.2±0.23ms     4.4 MB/sec    1.00      9.1±0.27ms     4.5 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.01  1973.8±87.56µs     8.4 MB/sec    1.00  1958.8±101.25µs     8.5 MB/sec
linter/default-rules/numpy/globals.py      1.00   235.4±10.11µs    12.5 MB/sec    1.00   235.2±17.67µs    12.5 MB/sec
linter/default-rules/pydantic/types.py     1.03      4.2±0.15ms     6.0 MB/sec    1.00      4.1±0.14ms     6.2 MB/sec
parser/large/dataset.py                    1.02      7.7±0.20ms     5.3 MB/sec    1.00      7.5±0.36ms     5.4 MB/sec
parser/numpy/ctypeslib.py                  1.04  1470.5±83.52µs    11.3 MB/sec    1.00  1417.3±51.93µs    11.7 MB/sec
parser/numpy/globals.py                    1.03    150.0±6.73µs    19.7 MB/sec    1.00    145.8±7.53µs    20.2 MB/sec
parser/pydantic/types.py                   1.05      3.3±0.11ms     7.6 MB/sec    1.00      3.2±0.09ms     8.0 MB/sec

format!("Could not write to {}, exiting", file.display())
})?;
}
}
Copy link
Member

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 the formatted.document().display() instead of or in addition to writing the file
  • --print-comments: Prints formatted.context().comments().debug() insteadof or in addition to writting the file

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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`
@konstin konstin changed the base branch from format-module to main June 5, 2023 07:25
@konstin
Copy link
Member Author

konstin commented Jun 5, 2023

Move this branch off the other so we can merge it first

@konstin konstin enabled auto-merge (squash) June 5, 2023 07:28
@konstin konstin merged commit d1d0696 into main Jun 5, 2023
@konstin konstin deleted the formatter-cli branch June 5, 2023 07:33
konstin added a commit that referenced this pull request Jun 13, 2023
* 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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants