Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(refactoring): keep move_method off override members and C# static classes (#2960)
Raghav Chamadiya1c3359986512
diff --git a/packages/cli/src/repowise/cli/commands/upgrade_flow.py b/packages/cli/src/repowise/cli/commands/upgrade_flow.pyindex 0f6c4e2c5..d0087159c 100644--- a/packages/cli/src/repowise/cli/commands/upgrade_flow.py+++ b/packages/cli/src/repowise/cli/commands/upgrade_flow.py@@ -288,6 +288,8 @@ async def _run_upgrade(# 4. Re-parse for ASTs + source (the only unavoidable re-work). The graph# is NOT rebuilt — generation traverses the rehydrated SQL graph.parsed_files, source_map, repo_structure = _reparse(repo_path, exclude_patterns)+ # The health pass below reads attributes SQL does not store.+ graph_builder.restore_parse_only_attrs(parsed_files)console.print(f"Re-parsed [cyan]{len(parsed_files)}[/cyan] files for doc generation ""(graph reused from index — not re-resolved)."diff --git a/packages/core/src/repowise/core/analysis/health/refactoring/move_method.py b/packages/core/src/repowise/core/analysis/health/refactoring/move_method.pyindex 6a5a0796d..b2c6759c9 100644--- a/packages/core/src/repowise/core/analysis/health/refactoring/move_method.py+++ b/packages/core/src/repowise/core/analysis/health/refactoring/move_method.py@@ -44,12 +44,14 @@ was handed looked like it envied the collector.The ``calls`` graph does not see field reads, so own-class use is also readoff the class's cohesion components: a method that shares a component holdingfields works on its own class's state and stays. A method that fulfils a-contract (``@Override``, a member its base class or interface declares, a-runtime contract name such as ``toString``) cannot move either, since the-type it overrides for is the reason it exists. Building the target through a-static factory (``OperationResult.Ok()``, any target member returning the-target type) counts as instantiating it, and an interface, an exception type-or a ``*Util``/``*Helper`` class is never a home for instance behaviour.+contract (``@Override``, an ``override`` / ``virtual`` / ``abstract``+modifier, a member its base class or interface declares, a runtime contract+name such as ``toString``) cannot move either, since the type it overrides for+is the reason it exists. Building the target through a static factory+(``OperationResult.Ok()``, any target member returning the target type) counts+as instantiating it, and an interface, an exception type, a ``*Util``/``*Helper``+class or a C# ``static class`` is never a home for instance behaviour. The+other ``partial`` fragments of the method's own class are its own class."""from __future__ import annotations@@ -89,6 +91,18 @@ _NON_TARGET_KINDS = frozenset({"interface", "trait", "protocol"})_NON_TARGET_SUFFIXES = ("Exception", "Error", "Util", "Utils", "Helper", "Helpers")# Java ``@Override``, Python ``@override`` / ``@typing.override``._OVERRIDE_DECORATOR = re.compile(r"@(?:[\w.]+\.)?[Oo]verride\b")+# Keyword modifiers (``Symbol.modifiers``) that bind a member to a type+# hierarchy: it overrides a base member (C#, Kotlin, Swift, Scala, TypeScript+# ``override``; VB.NET ``Overrides``) or is declared for subclasses to+# override (C# ``virtual``, Kotlin/Swift ``open``, ``abstract``; VB.NET+# ``Overridable`` / ``MustOverride``).+_CONTRACT_MODIFIERS = frozenset(+ {"override", "overrides", "virtual", "open", "overridable", "abstract", "mustoverride"}+)+# The class modifier that makes a type instance-less, per language: a C#+# ``static class`` holds only static helpers, like a ``*Util`` class. Java's+# ``static`` nested class is instantiable, so the keyword alone is not enough.+_STATIC_HOLDER_MODIFIER = {"csharp": "static"}# Factory-shaped names: a member returning its own class under one of these# names builds an instance (``OperationResult.Ok()``, ``Foo.of(...)``); a# getter such as ``parent() -> T`` does not.@@ -133,6 +147,22 @@ def _ancestors(graph: Any, class_id: str) -> set[str]:return seen+def _partial_fragments(graph: Any, file_path: str, class_name: str) -> set[str]:+ """The class ids of *class_name*'s ``partial`` fragments in other files.++ The graph links co-fragment files with ``partial_class`` import edges+ naming the type; every fragment is the same class, so none is foreign.+ """+ if file_path not in graph:+ return set()+ return {+ f"{other}::{class_name}"+ for _u, other, data in graph.out_edges(file_path, data=True)+ if data.get("hint_source") == "partial_class"+ and class_name in (data.get("imported_names") or ())+ }++def _class_name(graph: Any, class_id: str) -> str:return (_node(graph, class_id) or {}).get("name") or class_id.rsplit("::", 1)[-1]@@ -151,12 +181,14 @@ def _class_members(graph: Any, class_id: str, cache: dict[str, set[str]]) -> setdef _overrides(graph: Any, data: dict, own_class_id: str, language: str) -> bool:- """Whether the method fulfils a contract: an ``@Override`` annotation, a- runtime contract name, or a member an ancestor class or interface also- declares."""+ """Whether the method fulfils a contract: an ``@Override`` annotation or+ an ``override`` / ``virtual`` / ``abstract`` modifier, a runtime contract+ name, or a member an ancestor class or interface also declares."""name = data.get("name") or ""if any(_OVERRIDE_DECORATOR.search(d) for d in data.get("decorators") or ()):return True+ if _CONTRACT_MODIFIERS.intersection(data.get("modifiers") or ()):+ return Trueif is_contract_method(name, data.get("kind"), language):return Truedeclared = {@@ -195,10 +227,25 @@ def _builds(graph: Any, class_id: str, accessed: set[str]) -> bool:)+def _is_static_holder(graph: Any, class_id: str) -> bool:+ """A C# ``static class``. C# lets one ``partial`` fragment carry the+ ``static`` for all of them, so every fragment is asked."""+ node = _node(graph, class_id) or {}+ modifier = _STATIC_HOLDER_MODIFIER.get(node.get("language") or "")+ if modifier is None:+ return False+ file_path, _sep, name = class_id.rpartition("::")+ fragments = _partial_fragments(graph, file_path, name) | {class_id}+ return any(modifier in ((_node(graph, f) or {}).get("modifiers") or ()) for f in fragments)++def _never_a_target(graph: Any, class_id: str) -> bool:- """An interface, an exception type or a utility class."""+ """An interface, an exception type or a utility class (by name, or a C#+ ``static class``)."""if (_node(graph, class_id) or {}).get("kind") in _NON_TARGET_KINDS:return True+ if _is_static_holder(graph, class_id):+ return Truenames = [_class_name(graph, class_id)]names += [b.rsplit("::", 1)[-1] for b in _ancestors(graph, class_id)]return any(n.endswith(_NON_TARGET_SUFFIXES) for n in names)@@ -357,14 +404,14 @@ class MoveMethodDetector(RefactoringDetector):if not accessed:return None- own_accessed = accessed_by_class.get(own_class_id, set())- own_distinct = len(own_accessed)+ own_ids = _partial_fragments(graph, ctx.file_path, parent) | {own_class_id}+ own_distinct = len(set().union(*(accessed_by_class.get(c, ()) for c in own_ids)))if own_distinct > _MAX_OWN_MEMBERS:return None# Nearest foreign class by Jaccard distance (tie-break on class id).# A constructor call lands the class id in its own member set.- own_and_inherited = _ancestors(graph, own_class_id) | {own_class_id}+ own_and_inherited = _ancestors(graph, own_class_id) | own_idsforeign = [(c, m)for c, m in accessed_by_class.items()diff --git a/packages/core/src/repowise/core/ingestion/graph/_rehydrate.py b/packages/core/src/repowise/core/ingestion/graph/_rehydrate.pyindex ee96013be..eb7d28452 100644--- a/packages/core/src/repowise/core/ingestion/graph/_rehydrate.py+++ b/packages/core/src/repowise/core/ingestion/graph/_rehydrate.py@@ -49,6 +49,12 @@ _NODE_ATTR_KEYS = ("parent_symbol_id",)+# Symbol attributes ``graph_nodes`` has no column for. They come from the parse+# alone, so a rehydrated graph takes them back from the re-parse+# (:meth:`RehydrateMixin.restore_parse_only_attrs`); without them the+# refactoring detectors lose the ``@Override`` / ``override`` exemptions.+_PARSE_ONLY_SYMBOL_ATTRS = ("decorators", "modifiers")+class RehydrateMixin:"""Construct a :class:`GraphBuilder` from persisted rows instead of ASTs."""@@ -130,3 +136,18 @@ class RehydrateMixin:metrics=len(metrics) if metrics else 0,)return builder++ def restore_parse_only_attrs(self, parsed_files: Iterable[Any]) -> None:+ """Stamp the parse-only symbol attributes back onto rehydrated nodes.++ The first symbol under an id keeps its values, as in ``add_file``,+ where the first declared overload keeps the node.+ """+ nodes = self._graph.nodes # type: ignore[attr-defined]+ for parsed in parsed_files:+ for sym in parsed.symbols:+ node = nodes.get(sym.id)+ if node is None:+ continue+ for key in _PARSE_ONLY_SYMBOL_ATTRS:+ node.setdefault(key, getattr(sym, key))diff --git a/packages/core/src/repowise/core/ingestion/graph/builder.py b/packages/core/src/repowise/core/ingestion/graph/builder.pyindex 9d595821c..da99f99b8 100644--- a/packages/core/src/repowise/core/ingestion/graph/builder.py+++ b/packages/core/src/repowise/core/ingestion/graph/builder.py@@ -293,6 +293,7 @@ class GraphBuilder(MetricsMixin, ResolveMixin, EdgesMixin, SerializeMixin, Rehydparent_name=sym.parent_name,signature=sym.signature,decorators=sym.decorators,+ modifiers=sym.modifiers,is_exported_symbol=sym.is_exported_symbol,is_declaration=sym.is_declaration,docstring=sym.docstring,diff --git a/packages/core/src/repowise/core/ingestion/language_configs.py b/packages/core/src/repowise/core/ingestion/language_configs.pyindex c9e9c5156..9de1ba38b 100644--- a/packages/core/src/repowise/core/ingestion/language_configs.py+++ b/packages/core/src/repowise/core/ingestion/language_configs.py@@ -90,6 +90,10 @@ class LanguageConfig:# the edge they produce is ``references`` rather than ``calls``.reference_call_node_types: frozenset[str] = field(default_factory=frozenset)+ # Children of a declaration that hold its keyword modifiers (C#+ # ``modifier``, Kotlin ``modifiers``), read into ``Symbol.modifiers``.+ modifier_node_types: frozenset[str] = field(default_factory=frozenset)+LANGUAGE_CONFIGS: dict[str, LanguageConfig] = {"python": LanguageConfig(@@ -134,6 +138,7 @@ LANGUAGE_CONFIGS: dict[str, LanguageConfig] = {import_node_types=["import_statement"],export_node_types=["export_statement"],visibility_fn=ts_visibility,+ modifier_node_types=frozenset({"override_modifier"}),parent_extraction="nesting",parent_class_types=frozenset({"class_declaration", "abstract_class_declaration"}),declaration_node_types=frozenset({"function_signature", "method_signature"}),@@ -271,6 +276,7 @@ LANGUAGE_CONFIGS: dict[str, LanguageConfig] = {import_node_types=["import"],export_node_types=[],visibility_fn=kotlin_visibility,+ modifier_node_types=frozenset({"modifiers"}),parent_extraction="nesting",parent_class_types=frozenset({"class_declaration", "object_declaration"}),),@@ -309,6 +315,7 @@ LANGUAGE_CONFIGS: dict[str, LanguageConfig] = {import_node_types=["using_directive", "global_using_directive"],export_node_types=[],visibility_fn=csharp_visibility,+ modifier_node_types=frozenset({"modifier"}),parent_extraction="nesting",parent_class_types=frozenset({@@ -338,6 +345,7 @@ LANGUAGE_CONFIGS: dict[str, LanguageConfig] = {import_node_types=["imports_statement"],export_node_types=[],visibility_fn=vbnet_visibility,+ modifier_node_types=frozenset({"modifiers"}),parent_extraction="nesting",parent_class_types=frozenset({@@ -362,6 +370,7 @@ LANGUAGE_CONFIGS: dict[str, LanguageConfig] = {import_node_types=["import_declaration"],export_node_types=[],visibility_fn=swift_visibility,+ modifier_node_types=frozenset({"modifiers"}),parent_extraction="nesting",parent_class_types=frozenset({"class_declaration", "protocol_declaration"}),),@@ -409,6 +418,7 @@ LANGUAGE_CONFIGS: dict[str, LanguageConfig] = {import_node_types=["import_declaration"],export_node_types=[],visibility_fn=scala_visibility,+ modifier_node_types=frozenset({"modifiers"}),parent_extraction="nesting",parent_class_types=frozenset({"class_definition", "trait_definition", "object_definition"}),),diff --git a/packages/core/src/repowise/core/ingestion/models.py b/packages/core/src/repowise/core/ingestion/models.pyindex 6a43e0552..70bf49621 100644--- a/packages/core/src/repowise/core/ingestion/models.py+++ b/packages/core/src/repowise/core/ingestion/models.py@@ -226,6 +226,11 @@ class Symbol:# C# type declarations only: how many type parameters it declares, which is# what tells ``IFoo<T>`` from a same-named ``IFoo``. None elsewhere.type_parameter_count: int | None = None+ # Keyword modifiers the declaration writes, lowercased (``override``,+ # ``static``, ``abstract``...), for languages whose ``LanguageConfig``+ # names its modifier nodes. Access keywords land here too; ``visibility``+ # stays the field to read for those.+ modifiers: tuple[str, ...] = ()@dataclassdiff --git a/packages/core/src/repowise/core/ingestion/parser.py b/packages/core/src/repowise/core/ingestion/parser.pyindex 9bf348607..9e5fbc722 100644--- a/packages/core/src/repowise/core/ingestion/parser.py+++ b/packages/core/src/repowise/core/ingestion/parser.py@@ -25,6 +25,7 @@ Capture-name conventions (shared across ALL .scm files):from __future__ import annotationsimport re+import sysfrom collections.abc import Iterablefrom dataclasses import replacefrom functools import cache@@ -793,6 +794,35 @@ def _attribute_decorators(def_node: Node, language: str, src: str) -> list[str]:return []+def _declared_modifiers(def_node: Node, node_types: frozenset[str], src: str) -> tuple[str, ...]:+ """Lowercased keyword modifiers written in *def_node*'s modifier children.++ Keywords are the anonymous leaves of those children (C# ``modifier`` >+ ``override``, Kotlin ``modifiers`` > ``member_modifier`` > ``override``) or+ a named leaf that is itself a modifier (VB.NET ``modifier`` ``Overrides``).+ Named leaves such as Scala's ``protected[this]`` qualifier are not+ keywords. Annotations and attributes nested among them are skipped: they+ are decorators, not modifiers. The words are interned: a handful of+ distinct values repeat on every symbol.+ """+ if not node_types:+ return ()+ words: list[str] = []+ stack = [c for c in reversed(def_node.children) if c.type in node_types]+ while stack:+ node = stack.pop()+ if "annotation" in node.type or "attribute" in node.type:+ continue+ if node.child_count == 0:+ text = _node_text(node, src).strip()+ keyword = not node.is_named or "modifier" in node.type+ if keyword and text.isalpha():+ words.append(sys.intern(text.lower()))+ continue+ stack.extend(reversed(node.children))+ return tuple(words)++def _rust_outer_attributes(def_node: Node, src: str) -> list[str]:"""Rust: outer attributes (#[...]) are preceding siblings of the item."""attrs: list[str] = []@@ -1639,6 +1669,7 @@ class ASTParser:type_parameter_count=(_csharp_type_parameter_count(def_node) if language == "csharp" else None),+ modifiers=_declared_modifiers(def_node, config.modifier_node_types, src),)return symbol, def_nodediff --git a/packages/core/src/repowise/core/pipeline/orchestrator.py b/packages/core/src/repowise/core/pipeline/orchestrator.pyindex 4e512684f..5c140b37a 100644--- a/packages/core/src/repowise/core/pipeline/orchestrator.py+++ b/packages/core/src/repowise/core/pipeline/orchestrator.py@@ -358,6 +358,7 @@ async def run_pipeline(derive_environment_facts=derive_environment_facts,)traversal_stats = None+ graph_builder.restore_parse_only_attrs(parsed_files)# Rehydrated rows can predate the structural label, and nothing# else on this path recomputes it.label_co_change_structure(graph_builder, git_meta_map)diff --git a/tests/unit/cli/test_full_upgrade_progress.py b/tests/unit/cli/test_full_upgrade_progress.pyindex 5ac3c699e..bdf52dd36 100644--- a/tests/unit/cli/test_full_upgrade_progress.py+++ b/tests/unit/cli/test_full_upgrade_progress.py@@ -127,3 +127,11 @@ def test_full_upgrade_fts_cleanup_retries_after_failure(assert deleted == [["file_page:obsolete.py"]]assert indexed == ["file_page:current.py"]assert load_cleanup_debt(tmp_path)["fts"] == set()+++def test_full_upgrade_restores_parse_only_attrs_after_the_reparse() -> None:+ """The rehydrated graph lacks decorators/modifiers; the health pass needs them."""+ src = _upgrade_source()++ reparse = src.index("_reparse(repo_path")+ assert src.index("restore_parse_only_attrs(parsed_files)") > reparsediff --git a/tests/unit/health/test_refactoring_move_method.py b/tests/unit/health/test_refactoring_move_method.pyindex ee16e7c9e..5dc1be7c8 100644--- a/tests/unit/health/test_refactoring_move_method.py+++ b/tests/unit/health/test_refactoring_move_method.py@@ -397,3 +397,86 @@ def test_method_calling_an_inherited_member_or_in_a_trait_impl_does_not_move():cls.components = []cls.contract_impl = Trueassert _detect_java(_java_envy_graph(), classes=[cls]) == []+++# ---- keyword modifiers and partial classes (C#, Kotlin, VB.NET) ------------+++def _envy_graph_in(ext: str, language: str) -> nx.DiGraph:+ g = nx.DiGraph()+ _add_class(g, f"C.{ext}", "C", ["Envious", "Helper"])+ _add_class(g, f"T.{ext}", "T", ["Alpha", "Beta", "Gamma"])+ for node in g.nodes.values():+ node["language"] = language+ for m in ("Alpha", "Beta", "Gamma"):+ _call(g, f"C.{ext}::C.Envious", f"T.{ext}::T.{m}")+ return g+++def _detect_in(g: nx.DiGraph, file_path: str, language: str) -> list:+ ctx = RefactoringContext(file_path=file_path, language=language, nloc=40, graph=g)+ return [s for s in detect_refactorings(ctx) if s.refactoring_type == "move_method"]+++def test_csharp_envy_control_still_fires():+ g = _envy_graph_in("cs", "csharp")+ g.nodes["C.cs::C.Envious"]["modifiers"] = ("public", "static", "async")+ assert len(_detect_in(g, "C.cs", "csharp")) == 1+++def test_override_virtual_and_abstract_modifiers_never_move():+ for ext, language, modifiers in (+ ("cs", "csharp", ("protected", "override", "async")),+ ("cs", "csharp", ("public", "virtual")),+ ("cs", "csharp", ("public", "abstract")),+ ("kt", "kotlin", ("override",)),+ ("kt", "kotlin", ("open",)),+ ("vb", "vbnet", ("public", "overrides")),+ ):+ g = _envy_graph_in(ext, language)+ g.nodes[f"C.{ext}::C.Envious"]["modifiers"] = modifiers+ assert _detect_in(g, f"C.{ext}", language) == [], modifiers+++def test_csharp_static_class_is_never_a_move_target():+ g = _envy_graph_in("cs", "csharp")+ g.nodes["T.cs::T"]["modifiers"] = ("internal", "static")+ assert _detect_in(g, "C.cs", "csharp") == []+ # A Java ``static`` nested class has instances; it stays a target.+ g = _java_envy_graph()+ g.nodes["T.java::T"].update(language="java", modifiers=("static",))+ assert len(_detect_java(g)) == 1+++def test_static_written_on_another_partial_fragment_of_the_target():+ g = _envy_graph_in("cs", "csharp")+ g.add_node("T.Part.cs", node_type="file")+ g.add_node(+ "T.Part.cs::T",+ node_type="symbol",+ kind="class",+ name="T",+ file_path="T.Part.cs",+ language="csharp",+ modifiers=("public", "static", "partial"),+ )+ assert len(_detect_in(g, "C.cs", "csharp")) == 1 # unlinked fragment: no say+ g.add_edge(+ "T.cs", "T.Part.cs", edge_type="imports", imported_names=["T"], hint_source="partial_class"+ )+ assert _detect_in(g, "C.cs", "csharp") == []+++def test_other_partial_fragments_of_the_own_class_are_home():+ g = _envy_graph_in("cs", "csharp")+ # ``T`` here is a second fragment of ``C`` declared in another file.+ g = nx.relabel_nodes(g, {f"T.cs::T.{m}": f"T.cs::C.{m}" for m in ("Alpha", "Beta", "Gamma")})+ g = nx.relabel_nodes(g, {"T.cs::T": "T.cs::C"})+ g.nodes["T.cs::C"]["name"] = "C"+ for m in ("Alpha", "Beta", "Gamma"):+ g.nodes[f"T.cs::C.{m}"]["parent_name"] = "C"+ assert len(_detect_in(g, "C.cs", "csharp")) == 1 # unlinked: reads as foreign+ g.add_edge(+ "C.cs", "T.cs", edge_type="imports", imported_names=["C"], hint_source="partial_class"+ )+ assert _detect_in(g, "C.cs", "csharp") == []diff --git a/tests/unit/ingestion/parser/test_misc.py b/tests/unit/ingestion/parser/test_misc.pyindex 3a54bf03b..790831e51 100644--- a/tests/unit/ingestion/parser/test_misc.py+++ b/tests/unit/ingestion/parser/test_misc.py@@ -6,6 +6,8 @@ Covers Python, TypeScript, Go, Rust, Java, C++ — one test class per language.from __future__ import annotations+import pytest+from repowise.core.ingestion.parser import LANGUAGE_CONFIGS, ASTParserfrom tests.unit.ingestion.parser._helpers import _make_file_info@@ -132,3 +134,46 @@ def run():)"""assert self._calls(source, "m.py", "python")["target"] == 2+++_MODIFIER_CASES = (+ (+ "csharp",+ "A.cs",+ b"public static partial class P { [Obsolete] protected override void Impl() { } }",+ {"P": ("public", "static", "partial"), "Impl": ("protected", "override")},+ ),+ (+ "kotlin",+ "A.kt",+ b'open class A {\n @Deprecated("x") override fun f() {}\n fun g() {}\n}\n',+ {"A": ("open",), "f": ("override",), "g": ()},+ ),+ (+ "vbnet",+ "A.vb",+ b"Public Class A\n Public Overrides Function F() As Integer\n Return 1\n"+ b" End Function\nEnd Class\n",+ {"F": ("public", "overrides")},+ ),+ ("typescript", "a.ts", b"class A extends B { override f() {} }", {"f": ("override",)}),+ # Java writes ``@Override`` as an annotation; it stays a decorator.+ ("java", "A.java", b"class A { @Override public void f() {} }", {"f": ()}),+ # Scala access qualifiers name a scope, not a modifier.+ (+ "scala",+ "A.scala",+ b"class A { protected[this] def f(): Int = 1; override private[pkg] def g() = 2 }",+ {"f": ("protected",), "g": ("override", "private")},+ ),+)++[email protected](("language", "path", "source", "expected"), _MODIFIER_CASES)+def test_declared_modifiers(+ parser: ASTParser, language: str, path: str, source: bytes, expected: dict+) -> None:+ """Keyword modifiers land on ``Symbol.modifiers``; annotations do not."""+ result = parser.parse_file(_make_file_info(path, language), source)+ got = {s.name: s.modifiers for s in result.symbols if s.name in expected}+ assert got == expecteddiff --git a/tests/unit/ingestion/test_graph_rehydrate.py b/tests/unit/ingestion/test_graph_rehydrate.pyindex c6bfd7b84..63887a9e9 100644--- a/tests/unit/ingestion/test_graph_rehydrate.py+++ b/tests/unit/ingestion/test_graph_rehydrate.py@@ -12,7 +12,7 @@ from datetime import datetimefrom repowise.core.ingestion.graph import GraphBuilderfrom repowise.core.ingestion.graph._rehydrate import _NODE_ATTR_KEYS-from repowise.core.ingestion.models import FileInfo, Import, ParsedFile+from repowise.core.ingestion.models import FileInfo, Import, ParsedFile, Symboldef _fi(path: str) -> FileInfo:@@ -199,3 +199,31 @@ def test_reachability_root_survives_rehydration():hydrated = GraphBuilder.from_persisted(nodes, edges, original.file_metrics_snapshot())assert hydrated.graph().nodes["c.py"]["is_reachability_root"] is Trueassert not hydrated.graph().nodes["a.py"].get("is_reachability_root")+++def test_parse_only_symbol_attrs_come_back_from_the_reparse():+ sym = Symbol(+ id="a.py::A::f",+ name="f",+ qualified_name="a.A.f",+ kind="method",+ signature="f()",+ start_line=1,+ end_line=2,+ docstring=None,+ decorators=["@override"],+ parent_name="A",+ modifiers=("override",),+ )+ parsed = _parsed("a.py")+ parsed.symbols.append(sym)+ original = GraphBuilder()+ original.add_file(parsed)+ original.build()+ nodes, edges = _serialize(original)+ hydrated = GraphBuilder.from_persisted(nodes, edges, original.file_metrics_snapshot())+ assert "modifiers" not in hydrated.graph().nodes[sym.id]+ hydrated.restore_parse_only_attrs([parsed])+ node = hydrated.graph().nodes[sym.id]+ assert node["modifiers"] == ("override",)+ assert node["decorators"] == ["@override"]