Skip to content

Consistently wrap tokens in parser diagnostics in backticks instead of 'quotes'#21163

Merged
Gankra merged 1 commit intoastral-sh:mainfrom
lucach:tokens_backticks
Oct 31, 2025
Merged

Consistently wrap tokens in parser diagnostics in backticks instead of 'quotes'#21163
Gankra merged 1 commit intoastral-sh:mainfrom
lucach:tokens_backticks

Conversation

@lucach
Copy link
Copy Markdown
Contributor

@lucach lucach commented Oct 31, 2025

The parser currently uses single quotes to wrap tokens. This is inconsistent with the rest of ruff/ty, which use backticks.

For example, see the inconsistent diagnostics produced in this simple example: https://play.ty.dev/0a9d6eab-6599-4a1d-8e40-032091f7f50f

Consistently wrapping tokens in backticks produces uniform diagnostics. Following the style decision of #723, in #2889 some quotes were already switched into backticks.

This is also in line with Rust's guide on diagnostics (https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-structure):

When code or an identifier must appear in a message or label, it should be surrounded with backticks

The parser currently uses single quotes to wrap tokens.
This is inconsistent with the rest of ruff/ty, which use backticks.

For example, see the inconsistent diagnostics produced in this simple example: https://play.ty.dev/0a9d6eab-6599-4a1d-8e40-032091f7f50f

Consistently wrapping tokens in backticks produces uniform diagnostics.
Following astral-sh#723, in astral-sh#2889 some quotes were already switched into backticks.

This is also in line with Rust's guide on diagnostics
(https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-structure):

> When code or an identifier must appear in a message or label, it should be surrounded with backticks
@github-actions
Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+14 -14 violations, +0 -0 fixes in 1 projects; 54 projects unchanged)

openai/openai-cookbook (+14 -14 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --no-preview --select A,E703,F704,B015,B018,D100

- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:11: invalid-syntax: Expected ',', found name
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:11: invalid-syntax: Expected `,`, found name
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:16: invalid-syntax: Expected ',', found '='
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:16: invalid-syntax: Expected `,`, found `=`
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:22: invalid-syntax: Expected ',', found name
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:22: invalid-syntax: Expected `,`, found name
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:24: invalid-syntax: Expected ',', found ';'
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:24: invalid-syntax: Expected `,`, found `;`
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:11:27: invalid-syntax: Expected ',', found '='
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:11:27: invalid-syntax: Expected `,`, found `=`
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:11:34: invalid-syntax: Expected ',', found name
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:11:34: invalid-syntax: Expected `,`, found name
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:11:48: invalid-syntax: Expected ',', found ';'
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:11:48: invalid-syntax: Expected `,`, found `;`
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:11:49: invalid-syntax: Expected '}', found NonLogicalNewline
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:11:49: invalid-syntax: Expected `}`, found NonLogicalNewline
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:5:14: invalid-syntax: Expected ':', found '{'
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:5:14: invalid-syntax: Expected `:`, found `{`
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:6:25: invalid-syntax: Expected ',', found '='
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:6:25: invalid-syntax: Expected `,`, found `=`
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:6:46: invalid-syntax: Expected ',', found ';'
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:6:46: invalid-syntax: Expected `,`, found `;`
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:6:47: invalid-syntax: Expected '}', found newline
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:6:47: invalid-syntax: Expected `}`, found newline
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:6:9: invalid-syntax: Expected ',', found '{'
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:6:9: invalid-syntax: Expected `,`, found `{`
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:7:13: invalid-syntax: Expected ':', found 'break'
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:7:13: invalid-syntax: Expected `:`, found `break`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
invalid-syntax: 28 14 14 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+1843 -1843 violations, +0 -0 fixes in 9 projects; 46 projects unchanged)

apache/airflow (+7 -7 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL

- airflow-core/src/airflow/operators/__init__.py:30:13: E231 [*] Missing whitespace after ':'
+ airflow-core/src/airflow/operators/__init__.py:30:13: E231 [*] Missing whitespace after `:`
- airflow-core/src/airflow/operators/__init__.py:40:11: E231 [*] Missing whitespace after ':'
+ airflow-core/src/airflow/operators/__init__.py:40:11: E231 [*] Missing whitespace after `:`
- airflow-core/src/airflow/operators/__init__.py:43:15: E231 [*] Missing whitespace after ':'
+ airflow-core/src/airflow/operators/__init__.py:43:15: E231 [*] Missing whitespace after `:`
- airflow-core/src/airflow/operators/__init__.py:67:13: E231 [*] Missing whitespace after ':'
+ airflow-core/src/airflow/operators/__init__.py:67:13: E231 [*] Missing whitespace after `:`
- airflow-core/src/airflow/sensors/__init__.py:35:13: E231 [*] Missing whitespace after ':'
+ airflow-core/src/airflow/sensors/__init__.py:35:13: E231 [*] Missing whitespace after `:`
... 4 additional changes omitted for project

aws/aws-sam-cli (+8 -8 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview

- tests/integration/buildcmd/test_build_cmd.py:1030:39: E231 [*] Missing whitespace after ','
+ tests/integration/buildcmd/test_build_cmd.py:1030:39: E231 [*] Missing whitespace after `,`
- tests/integration/buildcmd/test_build_cmd.py:1755:39: E231 [*] Missing whitespace after ','
+ tests/integration/buildcmd/test_build_cmd.py:1755:39: E231 [*] Missing whitespace after `,`
- tests/integration/local/start_api/test_start_api.py:2386:40: E231 [*] Missing whitespace after ','
+ tests/integration/local/start_api/test_start_api.py:2386:40: E231 [*] Missing whitespace after `,`
- tests/integration/local/start_api/test_start_api.py:2405:40: E231 [*] Missing whitespace after ','
+ tests/integration/local/start_api/test_start_api.py:2405:40: E231 [*] Missing whitespace after `,`
- tests/integration/local/start_api/test_start_api.py:2424:40: E231 [*] Missing whitespace after ','
+ tests/integration/local/start_api/test_start_api.py:2424:40: E231 [*] Missing whitespace after `,`
... 6 additional changes omitted for project

binary-husky/gpt_academic (+508 -508 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview

- config.py:307:39: E231 [*] Missing whitespace after ','
+ config.py:307:39: E231 [*] Missing whitespace after `,`
- config.py:307:75: E231 [*] Missing whitespace after ','
+ config.py:307:75: E231 [*] Missing whitespace after `,`
- config.py:308:40: E231 [*] Missing whitespace after ','
+ config.py:308:40: E231 [*] Missing whitespace after `,`
- config.py:314:80: E231 [*] Missing whitespace after ','
+ config.py:314:80: E231 [*] Missing whitespace after `,`
- config.py:351:85: E231 [*] Missing whitespace after ','
+ config.py:351:85: E231 [*] Missing whitespace after `,`
- crazy_functions/Conversation_To_File.py:227:36: E231 [*] Missing whitespace after ':'
+ crazy_functions/Conversation_To_File.py:227:36: E231 [*] Missing whitespace after `:`
- crazy_functions/Document_Conversation_Wrap.py:31:47: E231 [*] Missing whitespace after ':'
... 1003 additional changes omitted for project

bokeh/bokeh (+1213 -1213 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL

- examples/advanced/extensions/tool.py:80:25: E231 [*] Missing whitespace after ','
+ examples/advanced/extensions/tool.py:80:25: E231 [*] Missing whitespace after `,`
- examples/advanced/extensions/tool.py:80:41: E231 [*] Missing whitespace after ','
+ examples/advanced/extensions/tool.py:80:41: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/arrowheads.py:17:27: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/arrowheads.py:17:27: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/colorbar_log.py:25:25: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/colorbar_log.py:25:25: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/colorbar_log.py:25:40: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/colorbar_log.py:25:40: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/legends_multi_index.py:6:21: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/legends_multi_index.py:6:21: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/legends_multi_index.py:6:23: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/legends_multi_index.py:6:23: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/legends_multi_index.py:6:30: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/legends_multi_index.py:6:30: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/legends_multi_index.py:6:32: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/legends_multi_index.py:6:32: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/legends_multi_index.py:6:41: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/legends_multi_index.py:6:41: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/legends_multi_index.py:6:43: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/legends_multi_index.py:6:43: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/legends_multi_index.py:6:50: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/legends_multi_index.py:6:50: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/legends_multi_index.py:6:52: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/legends_multi_index.py:6:52: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/title_additional.py:7:12: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/title_additional.py:7:12: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/title_additional.py:7:19: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/title_additional.py:7:19: E231 [*] Missing whitespace after `,`
- examples/basic/annotations/title_basic.py:5:12: E231 [*] Missing whitespace after ','
+ examples/basic/annotations/title_basic.py:5:12: E231 [*] Missing whitespace after `,`
... 2394 additional changes omitted for project

fronzbot/blinkpy (+22 -22 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview

- blinksync/blinksync.py:94:103: E231 [*] Missing whitespace after ','
+ blinksync/blinksync.py:94:103: E231 [*] Missing whitespace after `,`
- blinksync/forms.py:117:35: E231 [*] Missing whitespace after ':'
+ blinksync/forms.py:117:35: E231 [*] Missing whitespace after `:`
- blinksync/forms.py:117:51: E231 [*] Missing whitespace after ','
+ blinksync/forms.py:117:51: E231 [*] Missing whitespace after `,`
- blinksync/forms.py:117:62: E231 [*] Missing whitespace after ':'
+ blinksync/forms.py:117:62: E231 [*] Missing whitespace after `:`
- blinksync/forms.py:11:22: E231 [*] Missing whitespace after ','
+ blinksync/forms.py:11:22: E231 [*] Missing whitespace after `,`
... 34 additional changes omitted for project

milvus-io/pymilvus (+68 -68 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview

- examples/alter.py:34:105: E231 [*] Missing whitespace after ':'
+ examples/alter.py:34:105: E231 [*] Missing whitespace after `:`
- examples/alter.py:34:53: E231 [*] Missing whitespace after ','
+ examples/alter.py:34:53: E231 [*] Missing whitespace after `,`
- examples/alter.py:35:52: E231 [*] Missing whitespace after ','
+ examples/alter.py:35:52: E231 [*] Missing whitespace after `,`
- examples/alter.py:36:101: E231 [*] Missing whitespace after ':'
+ examples/alter.py:36:101: E231 [*] Missing whitespace after `:`
- examples/alter.py:36:106: E231 [*] Missing whitespace after ','
+ examples/alter.py:36:106: E231 [*] Missing whitespace after `,`
... 126 additional changes omitted for project

mlflow/mlflow (+1 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview

- mlflow/types/llm.py:829:42: E231 [*] Missing whitespace after ','
+ mlflow/types/llm.py:829:42: E231 [*] Missing whitespace after `,`

openai/openai-cookbook (+14 -14 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select A,E703,F704,B015,B018,D100

- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:11: invalid-syntax: Expected ',', found name
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:11: invalid-syntax: Expected `,`, found name
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:16: invalid-syntax: Expected ',', found '='
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:16: invalid-syntax: Expected `,`, found `=`
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:22: invalid-syntax: Expected ',', found name
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:22: invalid-syntax: Expected `,`, found name
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:24: invalid-syntax: Expected ',', found ';'
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:10:24: invalid-syntax: Expected `,`, found `;`
- examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:11:27: invalid-syntax: Expected ',', found '='
+ examples/mcp/databricks_mcp_cookbook.ipynb:cell 30:11:27: invalid-syntax: Expected `,`, found `=`
... 18 additional changes omitted for project

... Truncated remaining completed project reports due to GitHub comment length restrictions

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
E231 3658 1829 1829 0 0
invalid-syntax: 28 14 14 0 0

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Copy link
Copy Markdown
Contributor

@Gankra Gankra left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@Gankra Gankra added linter Related to the linter ty Multi-file analysis & type inference diagnostics Related to reporting of diagnostics. labels Oct 31, 2025
@Gankra Gankra changed the title Consistently wrap tokens in backticks Consistently wrap tokens in parser diagnostics in backticks instead of 'quotes' Oct 31, 2025
@Gankra Gankra changed the title Consistently wrap tokens in parser diagnostics in backticks instead of 'quotes' Consistently wrap tokens in parser diagnostics in \backticks\ instead of 'quotes' Oct 31, 2025
@Gankra Gankra changed the title Consistently wrap tokens in parser diagnostics in \backticks\ instead of 'quotes' Consistently wrap tokens in parser diagnostics in backticks instead of 'quotes' Oct 31, 2025
@Gankra Gankra merged commit 69b4c29 into astral-sh:main Oct 31, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diagnostics Related to reporting of diagnostics. linter Related to the linter ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants