fix(editor): align Python identifier colors and unused-parameter styling (#1572)
CI / Changes (push) Successful in 2s
Language smoke / Language smoke (kotlin) (push) Failing after 5s
Language smoke / Language smoke (go) (push) Failing after 7s
Language smoke / Language smoke (java) (push) Failing after 6s
Language smoke / Language smoke (python) (push) Failing after 4s
Language smoke / Language smoke (rust) (push) Failing after 5s
Language smoke / Language smoke (typescript) (push) Failing after 4s
CI / Plugins (SDK, official, fixtures) (push) Successful in 3m8s
CI / Cargo deny (push) Successful in 56s
CI / Remote server (linux musl) (push) Successful in 5m57s
CI / E2E (push) Failing after 15m56s
CI / Frontend (push) Failing after 24m3s
CI / Rust (ubuntu-22.04) (push) Failing after 46m51s
CI / Rust (macos-latest) (push) Canceled after 0s
CI / Rust (windows-latest) (push) Canceled after 0s

Python defaults diverged in several places: built-ins used the predefined magenta, __init__/__doc__ used function/self colours, instance fields the property colour, f-strings and byte strings the generic string colour, and the PEP 695 type keyword was uncoloured. Python now has its own tokens for built-ins, predefined definitions/usages, f-strings and byte strings; instance fields follow identifiers; type is a keyword. Unused parameters (not reported by Pyrefly) are greyed by a scope-aware local check that skips self/cls/_ names and signatures dictated elsewhere: stubs, @abstractmethod/@overload/@override, dunder methods and methods of classes with bases.

Co-authored-by: muutot <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Цей коміт міститься в:
authored and GitHub committed 2026-11-05 23:38:03 +08:00
1 джерело 4ca44ee815
коміт 875e049dcd
14 files changed
+239 -15

No files matched your search

+7
Переглянути файл
@@ -12,6 +12,13 @@ describe("color schemes", () => {
expect(schemeTokens("light").get("--syn-keyword")).toBe("#0033b3");
expect(schemeTokens("dark").get("--syn-keyword")).toBe("#cf8e6d");
expect(schemeTokens("light").get("--bg-editor")).not.toMatch(/var\(/);
const dark = schemeTokens("dark");
expect(dark.get("--syn-python-builtin")).toBe("#8888c6");
expect(dark.get("--syn-python-predefined-definition")).toBe("#b200b2");
expect(dark.get("--syn-python-predefined-usage")).toBe("#b200b2");
expect(dark.get("--syn-python-instance-attribute")).toBe("#bcbec4");
expect(dark.get("--syn-python-fstring")).toBe("#a5c261");
expect(dark.get("--syn-python-bytes")).toBe("#a5c261");
});
it("gives PHP variables and function calls their own colours, as PhpStorm (#1532)", () => {
+2 -1
Переглянути файл
@@ -142,6 +142,7 @@ const BASE_ATTRIBUTES: readonly AttributeDef[] = [
syn("pyBraces", "Braces", ["Python"], "python-braces"),
syn("pyNestedFunction", "Nested function definition", ["Python"], "python-nested-function"),
syn("pyBytes", "Byte string", ["Python"], "python-bytes"),
syn("pyFString", "F-string", ["Python"], "python-fstring"),
syn("pyPredefinedDefinition", "Predefined function definition", ["Python"], "python-predefined-definition"),
syn("pyPredefinedUsage", "Predefined name usage", ["Python"], "python-predefined-usage"),
syn("pyFormat", "Format specifier", ["Python"], "python-format"),
@@ -156,7 +157,7 @@ const BASE_ATTRIBUTES: readonly AttributeDef[] = [
},
syn("pyKeywordArg", "Keyword argument", ["Python"], "keyword-arg"),
syn("pyDocstring", "Docstring", ["Python"], "docstring"),
syn("pyBuiltin", "Built-in name", ["Python"], "predefined"),
syn("pyBuiltin", "Built-in name", ["Python"], "python-builtin"),
syn("pyDecorator", "Decorator", ["Python"], "annotation"),
syn("pyLocalVariable", "Local variable", ["Python"], "python-local-variable"),
syn("pyGlobalVariable", "Global variable", ["Python"], "python-global-variable"),
+8
Переглянути файл
@@ -122,6 +122,14 @@ describe(".icls schemes", () => {
for (const [name, value] of names) expect(attrs[name]?.foreground).toBe(`#${value}`);
});
it("imports the Python f-string colour", () => {
const xml =
'<scheme name="F"><attributes><option name="PY.STRING.F"><value>' +
'<option name="FOREGROUND" value="808080"/></value></option></attributes></scheme>';
const { id, customs } = importScheme({}, parseIcls(xml).scheme);
expect(parseIcls(exportIcls(id, customs)).scheme.attributes.pyFString?.foreground).toBe("#808080");
});
it("imports the global variable colour", () => {
const xml =
'<scheme name="G" parent_scheme="Darcula"><attributes><option name="DEFAULT_GLOBAL_VARIABLE"><value>' +
+1
Переглянути файл
@@ -149,6 +149,7 @@ Object.assign(ATTRIBUTE_NAMES, {
"PY.PREDEFINED_DEFINITION": "pyPredefinedDefinition",
"PY.PREDEFINED_USAGE": "pyPredefinedUsage",
"PY.STRING.B": "pyBytes",
"PY.STRING.F": "pyFString",
"PY.VALID_STRING_ESCAPE": "escape",
"PY.OPERATION_SIGN": "operator",
});
+1
Переглянути файл
@@ -30,6 +30,7 @@
"Predefined name usage": "预定义名称引用",
"Predefined function definition": "预定义函数定义",
"Byte string": "字节字符串",
"F-string": "F 字符串",
"Nested function definition": "嵌套函数定义",
"Local variable": "局部变量",
"Global variable": "全局变量",