From 21d77512b61e684b7eff98ffb66a5c5142c3fd41 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Tue, 18 Feb 2025 22:26:18 +0000 Subject: [PATCH] Include all ident parts in keys (#31) --- common/src/table.rs | 5 +++-- pyproject-fmt/rust/src/data/ruff-order.expected.toml | 1 + pyproject-fmt/rust/src/data/ruff-order.start.toml | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common/src/table.rs b/common/src/table.rs index f526e85..72f9022 100644 --- a/common/src/table.rs +++ b/common/src/table.rs @@ -312,13 +312,14 @@ pub fn collapse_sub_tables(tables: &mut Tables, name: &str) { let child_node = child.as_node().unwrap(); for mut entry in child_node.children_with_tokens() { if entry.kind() == KEY { + let mut key_parts = vec![String::from(sub_name)]; for array_entry_value in entry.as_node().unwrap().children_with_tokens() { if array_entry_value.kind() == IDENT { let txt = load_text(array_entry_value.as_token().unwrap().text(), IDENT); - entry = make_key(format!("{sub_name}.{txt}").as_str()); - break; + key_parts.push(txt); } } + entry = make_key(&key_parts.join(".")); } to_insert.push(entry); } diff --git a/pyproject-fmt/rust/src/data/ruff-order.expected.toml b/pyproject-fmt/rust/src/data/ruff-order.expected.toml index c9f45ab..666a0f7 100644 --- a/pyproject-fmt/rust/src/data/ruff-order.expected.toml +++ b/pyproject-fmt/rust/src/data/ruff-order.expected.toml @@ -165,6 +165,7 @@ lint.flake8-self.extend-ignore-names = [ "ALPHA", "Bar", ] +lint.flake8-tidy-imports.banned-api."foo".msg = "Use bar instead" lint.flake8-tidy-imports.banned-module-level-imports = [ "ALPHA", "Bar", diff --git a/pyproject-fmt/rust/src/data/ruff-order.start.toml b/pyproject-fmt/rust/src/data/ruff-order.start.toml index 6d68fc0..5130b8c 100644 --- a/pyproject-fmt/rust/src/data/ruff-order.start.toml +++ b/pyproject-fmt/rust/src/data/ruff-order.start.toml @@ -88,6 +88,8 @@ docstring-quotes = 'single' extend-ignore-names = ['Bar', 'ALPHA'] [tool.ruff.lint.flake8-tidy-imports] banned-module-level-imports = ['Bar', 'ALPHA'] +[tool.ruff.lint.flake8-tidy-imports.banned-api] +"foo".msg = "Use bar instead" [tool.ruff.lint.flake8-type-checking] exempt-modules = ['Bar', 'ALPHA'] [tool.ruff.lint.flake8-unused-arguments]