Skip to content

Rename CodebaseGraph to CodebaseContext #405

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

Merged
merged 12 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/codegen/runner/diff/get_raw_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def patch_to_limited_diff_string(patch, codebase: Codebase, max_lines=10000):

# Add flags that are not in the diff
filenames = [patched_file.path for patched_file in patch]
flags_not_in_diff = list(filter(lambda flag: flag.symbol.filepath not in filenames, codebase.G.flags._flags))
flags_not_in_diff = list(filter(lambda flag: flag.symbol.filepath not in filenames, codebase.ctx.flags._flags))

for flag in flags_not_in_diff:
filename = flag.symbol.filepath
Expand All @@ -39,7 +39,7 @@ def patch_to_limited_diff_string(patch, codebase: Codebase, max_lines=10000):
patch.append(patched_file)

for patched_file in patch:
filtered_flags = filter(lambda flag: flag.symbol.filepath == patched_file.path, codebase.G.flags._flags)
filtered_flags = filter(lambda flag: flag.symbol.filepath == patched_file.path, codebase.ctx.flags._flags)
sorted_flags = list(map(lambda flag: flag.symbol.start_point.row + 1, filtered_flags))
sorted_flags.sort()

Expand Down
8 changes: 4 additions & 4 deletions src/codegen/runner/sandbox/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"""Runs the execute_func in find_mode to find flags"""
self.codebase.set_find_mode(True)
await self._execute_with_try_catch(execute_func, commit=False)
code_flags = self.codebase.G.flags._flags
logger.info(f"> Found {len(self.codebase.G.flags._flags)} CodeFlags")
code_flags = self.codebase.ctx.flags._flags
logger.info(f"> Found {len(self.codebase.ctx.flags._flags)} CodeFlags")

Check warning on line 40 in src/codegen/runner/sandbox/executor.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/runner/sandbox/executor.py#L39-L40

Added lines #L39 - L40 were not covered by tests
return code_flags

async def find_flag_groups(self, code_flags: list[CodeFlag], grouping_config: GroupingConfig) -> list[Group]:
Expand Down Expand Up @@ -77,7 +77,7 @@
run_results.append(run_result)
head_branches.append(created_branch)

self.codebase.G.flags._flags.clear()
self.codebase.ctx.flags._flags.clear()

Check warning on line 80 in src/codegen/runner/sandbox/executor.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/runner/sandbox/executor.py#L80

Added line #L80 was not covered by tests
return run_results, head_branches

async def execute(self, execute_func: Callable, group: Group | None = None, session_options: SessionOptions = SessionOptions()) -> CodemodRunResult:
Expand Down Expand Up @@ -155,7 +155,7 @@
"messageType": str(flag.message_type),
"messageRecipient": flag.message_recipient,
}
for flag in self.codebase.G.flags._flags
for flag in self.codebase.ctx.flags._flags
]
result.flags = flags
if result.observation_meta is None:
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/runner/sandbox/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ async def cleanup_after_codemod(self, is_exception: bool = False):
if is_exception:
# TODO: instead of committing transactions, we should just rollback
logger.info("Committing pending transactions due to exception")
self.runner.codebase.G.commit_transactions(sync_graph=False)
self.runner.codebase.ctx.commit_transactions(sync_graph=False)
self.runner.reset_runner()
self.server_info.is_running_codemod = False
2 changes: 1 addition & 1 deletion src/codegen/runner/sandbox/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,5 @@
response.results = run_results
response.branches = branches

self.codebase.G.flags._flags.clear()
self.codebase.ctx.flags._flags.clear()

Check warning on line 115 in src/codegen/runner/sandbox/runner.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/runner/sandbox/runner.py#L115

Added line #L115 was not covered by tests
return response
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codegen.sdk.core.placeholder.placeholder_type import TypePlaceholder

ATTRIBUTES_TO_IGNORE = [
"G",
"ctx",
"node_id",
"angular",
"model_config",
Expand All @@ -19,7 +19,6 @@
"node_type",
"ts_node",
"file_node_id",
"G",
"statement_type",
"assignment_types",
]
Expand Down
10 changes: 5 additions & 5 deletions src/codegen/sdk/codebase/codebase_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def get_codebase_summary(codebase: Codebase) -> str:
node_summary = f"""Contains {len(codebase.G.get_nodes())} nodes
node_summary = f"""Contains {len(codebase.ctx.get_nodes())} nodes
- {len(list(codebase.files))} files
- {len(list(codebase.imports))} imports
- {len(list(codebase.external_modules))} external_modules
Expand All @@ -19,10 +19,10 @@ def get_codebase_summary(codebase: Codebase) -> str:
\t- {len(list(codebase.global_vars))} global_vars
\t- {len(list(codebase.interfaces))} interfaces
"""
edge_summary = f"""Contains {len(codebase.G.edges)} edges
- {len([x for x in codebase.G.edges if x[2].type == EdgeType.SYMBOL_USAGE])} symbol -> used symbol
- {len([x for x in codebase.G.edges if x[2].type == EdgeType.IMPORT_SYMBOL_RESOLUTION])} import -> used symbol
- {len([x for x in codebase.G.edges if x[2].type == EdgeType.EXPORT])} export -> exported symbol
edge_summary = f"""Contains {len(codebase.ctx.edges)} edges
- {len([x for x in codebase.ctx.edges if x[2].type == EdgeType.SYMBOL_USAGE])} symbol -> used symbol
- {len([x for x in codebase.ctx.edges if x[2].type == EdgeType.IMPORT_SYMBOL_RESOLUTION])} import -> used symbol
- {len([x for x in codebase.ctx.edges if x[2].type == EdgeType.EXPORT])} export -> exported symbol
"""

return f"{node_summary}\n{edge_summary}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_node_classes(programming_language: ProgrammingLanguage) -> NodeClasses:
raise ValueError(msg)


class CodebaseGraph:
class CodebaseContext:
"""MultiDiGraph Wrapper with TransactionManager"""

# =====[ __init__ attributes ]=====
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/sdk/codebase/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
from codegen.sdk.enums import ProgrammingLanguage

if TYPE_CHECKING:
from codegen.sdk.codebase.codebase_graph import CodebaseGraph
from codegen.sdk.codebase.codebase_context import CodebaseContext


class ConfigParser(ABC):
def __init__(self):
pass

@abstractmethod
def parse_configs(self, codebase_graph: "CodebaseGraph"): ...
def parse_configs(self, codebase_context: "CodebaseContext"): ...


def get_config_parser_for_language(language: ProgrammingLanguage, codebase_graph: "CodebaseGraph") -> ConfigParser | None:
def get_config_parser_for_language(language: ProgrammingLanguage, codebase_context: "CodebaseContext") -> ConfigParser | None:
from codegen.sdk.typescript.config_parser import TSConfigParser

if language == ProgrammingLanguage.TYPESCRIPT:
return TSConfigParser(codebase_graph)
return TSConfigParser(codebase_context)

return None
6 changes: 3 additions & 3 deletions src/codegen/sdk/codebase/factory/get_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from codegen.git.repo_operator.local_repo_operator import LocalRepoOperator
from codegen.git.schemas.repo_config import BaseRepoConfig
from codegen.sdk.codebase.codebase_graph import CodebaseGraph
from codegen.sdk.codebase.codebase_context import CodebaseContext
from codegen.sdk.codebase.config import CodebaseConfig, GSFeatureFlags, ProjectConfig, SessionOptions, TestFlags
from codegen.sdk.codebase.factory.codebase_factory import CodebaseFactory
from codegen.sdk.core.codebase import Codebase, PyCodebaseType, TSCodebaseType
Expand Down Expand Up @@ -108,12 +108,12 @@ def get_codebase_graph_session(
files: dict[str, str] = {},
sync_graph: bool = True,
session_options: SessionOptions = SessionOptions(),
) -> Generator[CodebaseGraph, None, None]:
) -> Generator[CodebaseContext, None, None]:
"""Gives you a Codebase2 operating on the files you provided as a dict"""
op = LocalRepoOperator.create_from_files(repo_path=tmpdir, files=files)
config = CodebaseConfig(feature_flags=TestFlags)
projects = [ProjectConfig(repo_operator=op, programming_language=programming_language)]
graph = CodebaseGraph(projects=projects, config=config)
graph = CodebaseContext(projects=projects, config=config)
with graph.session(sync_graph=sync_graph, session_options=session_options):
try:
yield graph
Expand Down
6 changes: 3 additions & 3 deletions src/codegen/sdk/codebase/node_classes/py_node_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
from codegen.sdk.python.statements.import_statement import PyImportStatement


def parse_subscript(node: TSNode, file_node_id, G, parent):
def parse_subscript(node: TSNode, file_node_id, ctx, parent):
if (node.prev_named_sibling and node.prev_named_sibling.text.decode("utf-8") == "TypeAlias") or isinstance(parent, Type):
return PyGenericType(node, file_node_id, G, parent)
return SubscriptExpression(node, file_node_id, G, parent)
return PyGenericType(node, file_node_id, ctx, parent)
return SubscriptExpression(node, file_node_id, ctx, parent)


PyExpressionMap = {
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/sdk/codebase/range_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def nodes(self) -> list[Editable]:
def children(self) -> dict[Editable, list[Editable]]:
ret = defaultdict(list)
for node in self.nodes:
# if node.G.config.feature_flags.debug:
# if node.ctx.config.feature_flags.debug:
# assert node.parent != node, node.__class__
if node.parent != node:
ret[node.parent].append(node)
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/sdk/codebase/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
self.exec_func = exec_func

def _generate_new_content_bytes(self) -> bytes:
new_bytes = bytes(self.new_content, encoding="utf-8")

Check failure on line 161 in src/codegen/sdk/codebase/transactions.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument 1 to "bytes" has incompatible type "str | None"; expected "str" [arg-type]
content_bytes = self.file.content_bytes
head = content_bytes[: self.insert_byte]
tail = content_bytes[self.insert_byte :]
Expand All @@ -178,7 +178,7 @@
def diff_str(self) -> str:
"""Human-readable string representation of the change"""
diff = "".join(unified_diff(self.file.content.splitlines(True), self._generate_new_content_bytes().decode("utf-8").splitlines(True)))
return f"Insert {len(self.new_content)} bytes at bytes ({self.start_byte}, {self.end_byte})\n{diff}"

Check failure on line 181 in src/codegen/sdk/codebase/transactions.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument 1 to "len" has incompatible type "str | None"; expected "Sized" [arg-type]


class EditTransaction(Transaction):
Expand Down Expand Up @@ -262,7 +262,7 @@
priority: int = 0,
) -> None:
super().__init__(0, 0, file.path, priority=priority, new_content=new_file_path)
self.new_file_path = file.G.to_absolute(new_file_path)
self.new_file_path = file.ctx.to_absolute(new_file_path)
self.file = file

def execute(self) -> None:
Expand Down
16 changes: 8 additions & 8 deletions src/codegen/sdk/codebase/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@

def post_init_validation(codebase: CodebaseType) -> PostInitValidationStatus:
"""Post codebase._init_graph verifies that the built graph is valid."""
from codegen.sdk.codebase.codebase_graph import GLOBAL_FILE_IGNORE_LIST
from codegen.sdk.codebase.codebase_context import GLOBAL_FILE_IGNORE_LIST

# Verify the graph has nodes
if len(codebase.G.nodes) == 0:
if len(codebase.ctx.nodes) == 0:
return PostInitValidationStatus.NO_NODES

# Verify the graph has the same number of files as there are in the repo
if len(codebase.files) != len(list(codebase.op.iter_files(codebase.G.projects[0].subdirectories, extensions=codebase.G.extensions, ignore_list=GLOBAL_FILE_IGNORE_LIST))):
if len(codebase.files) != len(list(codebase.op.iter_files(codebase.ctx.projects[0].subdirectories, extensions=codebase.ctx.extensions, ignore_list=GLOBAL_FILE_IGNORE_LIST))):

Check failure on line 40 in src/codegen/sdk/codebase/validation.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument 1 to "len" has incompatible type overloaded function; expected "Sized" [arg-type]
return PostInitValidationStatus.MISSING_FILES

# Verify import resolution
Expand All @@ -64,14 +64,14 @@

def post_sync_validation(codebase: CodebaseType) -> bool:
"""Post codebase.sync, checks that the codebase graph is in a valid state (i.e. not corrupted by codebase.sync)"""
if len(codebase.G.all_syncs) > 0 or len(codebase.G.pending_syncs) > 0 or len(codebase.G.transaction_manager.to_commit()) > 0:
if len(codebase.ctx.all_syncs) > 0 or len(codebase.ctx.pending_syncs) > 0 or len(codebase.ctx.transaction_manager.to_commit()) > 0:

Check warning on line 67 in src/codegen/sdk/codebase/validation.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/codebase/validation.py#L67

Added line #L67 was not covered by tests
msg = "Can only be called on a reset codebase"
raise NotImplementedError(msg)
if not codebase.G.config.feature_flags.track_graph:
if not codebase.ctx.config.feature_flags.track_graph:

Check warning on line 70 in src/codegen/sdk/codebase/validation.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/codebase/validation.py#L70

Added line #L70 was not covered by tests
msg = "Can only be called with track_graph=true"
raise NotImplementedError(msg)
return len(dict.fromkeys(codebase.G.old_graph.nodes())) == len(dict.fromkeys(codebase.G.nodes)) and len(dict.fromkeys(codebase.G.old_graph.weighted_edge_list())) == len(
dict.fromkeys(codebase.G.edges)
return len(dict.fromkeys(codebase.ctx.old_graph.nodes())) == len(dict.fromkeys(codebase.ctx.nodes)) and len(dict.fromkeys(codebase.ctx.old_graph.weighted_edge_list())) == len(

Check failure on line 73 in src/codegen/sdk/codebase/validation.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot determine type of "old_graph" [has-type]

Check warning on line 73 in src/codegen/sdk/codebase/validation.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/codebase/validation.py#L73

Added line #L73 was not covered by tests
dict.fromkeys(codebase.ctx.edges)
)


Expand Down Expand Up @@ -140,7 +140,7 @@
from codegen.sdk.core.external_module import ExternalModule

if isinstance(node, ExternalModule):
message += "External Module persisted with following dependencies: " + str(list((node.G.get_node(source), edge) for source, _, edge in node.G.in_edges(node.node_id)))
message += "External Module persisted with following dependencies: " + str(list((node.ctx.get_node(source), edge) for source, _, edge in node.ctx.in_edges(node.node_id)))

Check warning on line 143 in src/codegen/sdk/codebase/validation.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/codebase/validation.py#L143

Added line #L143 was not covered by tests
return message


Expand Down
24 changes: 12 additions & 12 deletions src/codegen/sdk/core/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from tree_sitter import Node as TSNode

from codegen.sdk.codebase.codebase_graph import CodebaseGraph
from codegen.sdk.codebase.codebase_context import CodebaseContext
from codegen.sdk.codebase.resolution_stack import ResolutionStack
from codegen.sdk.core.expressions.type import Type
from codegen.sdk.core.interfaces.editable import Editable
Expand Down Expand Up @@ -58,37 +58,37 @@
_left: Expression[Self]
symbol_type = SymbolType.GlobalVar

def __init__(self, ts_node: TSNode, file_node_id: NodeId, G: CodebaseGraph, parent: Parent, left: TSNode, value: TSNode, name_node: TSNode, type: Type | None = None) -> None:
def __init__(self, ts_node: TSNode, file_node_id: NodeId, ctx: CodebaseContext, parent: Parent, left: TSNode, value: TSNode, name_node: TSNode, type: Type | None = None) -> None:
self._unique_node = name_node # HACK: This prevents deduplication of Assignments
super().__init__(ts_node, file_node_id, G, parent=parent, name_node=name_node, name_node_type=Name)
super().__init__(ts_node, file_node_id, ctx, parent=parent, name_node=name_node, name_node_type=Name)
self._left = self._parse_expression(left, default=Name)
self._value_node = self._parse_expression(value)
self.type = type
if self.type is None:
self._init_type()

@classmethod
def _from_left_and_right_nodes(cls, ts_node: TSNode, file_node_id: NodeId, G: CodebaseGraph, parent: Parent, left_node: TSNode, right_node: TSNode) -> list[Assignment]:
left = G.parser.parse_expression(left_node, file_node_id, G, parent)
value = G.parser.parse_expression(right_node, file_node_id, G, parent)
def _from_left_and_right_nodes(cls, ts_node: TSNode, file_node_id: NodeId, ctx: CodebaseContext, parent: Parent, left_node: TSNode, right_node: TSNode) -> list[Assignment]:
left = ctx.parser.parse_expression(left_node, file_node_id, ctx, parent)
value = ctx.parser.parse_expression(right_node, file_node_id, ctx, parent)

Check warning on line 73 in src/codegen/sdk/core/assignment.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/core/assignment.py#L72-L73

Added lines #L72 - L73 were not covered by tests

if isinstance(left, Collection | Dict):
assignments = []
for var in left.symbols:
# Make a deep copy of the value expression for each child
value = G.parser.parse_expression(right_node, file_node_id, G, parent)
assignments.extend(cls._from_value_expression(ts_node, file_node_id, G, parent, left, value, var.ts_node))
value = ctx.parser.parse_expression(right_node, file_node_id, ctx, parent)
assignments.extend(cls._from_value_expression(ts_node, file_node_id, ctx, parent, left, value, var.ts_node))

Check warning on line 80 in src/codegen/sdk/core/assignment.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/core/assignment.py#L79-L80

Added lines #L79 - L80 were not covered by tests
return sort_editables(assignments)
return cls._from_value_expression(ts_node, file_node_id, G, parent, left, value, left_node)
return cls._from_value_expression(ts_node, file_node_id, ctx, parent, left, value, left_node)

Check warning on line 82 in src/codegen/sdk/core/assignment.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/core/assignment.py#L82

Added line #L82 was not covered by tests

@classmethod
def _from_value_expression(
cls, ts_node: TSNode, file_node_id: NodeId, G: CodebaseGraph, parent: Parent, left: Expression[Self], value: Expression[Self] | list[Expression], name_node: TSNode
cls, ts_node: TSNode, file_node_id: NodeId, ctx: CodebaseContext, parent: Parent, left: Expression[Self], value: Expression[Self] | list[Expression], name_node: TSNode
) -> list[Assignment]:
assignments = [cls(ts_node, file_node_id, G, parent, left, value, name_node)]
assignments = [cls(ts_node, file_node_id, ctx, parent, left, value, name_node)]

Check warning on line 88 in src/codegen/sdk/core/assignment.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/core/assignment.py#L88

Added line #L88 was not covered by tests
if value and isinstance(value, MultiExpression) and isinstance(value.expressions[0], Assignment):
for expr in value.expressions:
assignments.extend(cls._from_value_expression(expr.ts_node, file_node_id, G, parent, expr.left, expr.value, expr.get_name().ts_node))
assignments.extend(cls._from_value_expression(expr.ts_node, file_node_id, ctx, parent, expr.left, expr.value, expr.get_name().ts_node))

Check warning on line 91 in src/codegen/sdk/core/assignment.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/core/assignment.py#L91

Added line #L91 was not covered by tests
return sort_editables(assignments)

@noapidoc
Expand Down
12 changes: 6 additions & 6 deletions src/codegen/sdk/core/autocommit/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
def wrapper(wrapped: Callable[P, T], instance: "Editable", args, kwargs) -> T:
if instance is None:
instance = args[0]
if instance.removed:

Check failure on line 48 in src/codegen/sdk/core/autocommit/decorators.py

View workflow job for this annotation

GitHub Actions / mypy

error: "Editable[Any]" has no attribute "removed"; maybe "remove" or "_remove"? [attr-defined]

Check failure on line 48 in src/codegen/sdk/core/autocommit/decorators.py

View workflow job for this annotation

GitHub Actions / mypy

error: "Editable[Any]" has no attribute "removed"; maybe "remove" or "_remove"? [attr-defined]
logger.warning("Editing a removed node")
autocommit = instance.G._autocommit
autocommit = instance.ctx._autocommit

Check warning on line 50 in src/codegen/sdk/core/autocommit/decorators.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/core/autocommit/decorators.py#L50

Added line #L50 was not covered by tests
logger.debug("Writing node %r,%r", instance, wrapped)
with autocommit.write_state(instance, commit=commit):
return wrapped(*args, **kwargs)
Expand All @@ -59,8 +59,8 @@
def remover(
wrapped: Callable[P, T],
instance: Union["Symbol", None] = None,
args: P.args = None,

Check failure on line 62 in src/codegen/sdk/core/autocommit/decorators.py

View workflow job for this annotation

GitHub Actions / mypy

error: ParamSpec components are not allowed here [valid-type]
kwargs: P.kwargs = None,

Check failure on line 63 in src/codegen/sdk/core/autocommit/decorators.py

View workflow job for this annotation

GitHub Actions / mypy

error: ParamSpec components are not allowed here [valid-type]
) -> Callable[P, T]:
"""Indicates the node will be removed at the end of this method.

Expand All @@ -69,11 +69,11 @@
if instance is None:
instance = args[0]
logger.debug("Removing node %r, %r", instance, wrapped)
with instance.G._autocommit.write_state(instance):
with instance.ctx._autocommit.write_state(instance):

Check warning on line 72 in src/codegen/sdk/core/autocommit/decorators.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/core/autocommit/decorators.py#L72

Added line #L72 was not covered by tests
ret = wrapped(*args, **kwargs)
# instance.G._autocommit.set_pending(instance, REMOVED)
# instance.ctx._autocommit.set_pending(instance, REMOVED)
instance.removed = True

Check failure on line 75 in src/codegen/sdk/core/autocommit/decorators.py

View workflow job for this annotation

GitHub Actions / mypy

error: Item "Symbol[Any, Any]" of "Symbol[Any, Any] | Any" has no attribute "removed" [union-attr]
return ret

Check failure on line 76 in src/codegen/sdk/core/autocommit/decorators.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible return value type (got "T", expected "Callable[P, T]") [return-value]


@wrapt.decorator(enabled=enabled)
Expand All @@ -86,7 +86,7 @@
"""Indicates the method is use in debugging/logs."""
if instance is None:
instance = args[0]
autocommit = instance.G._autocommit
autocommit = instance.ctx._autocommit

Check warning on line 89 in src/codegen/sdk/core/autocommit/decorators.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/core/autocommit/decorators.py#L89

Added line #L89 was not covered by tests
old_state = autocommit.enter_state(AutoCommitState.Special)
try:
ret = wrapped(*args, **kwargs)
Expand All @@ -108,8 +108,8 @@
"""
if instance is None:
instance = args[0]
with instance.G._autocommit.write_state(instance, move=True):
with instance.ctx._autocommit.write_state(instance, move=True):

Check warning on line 111 in src/codegen/sdk/core/autocommit/decorators.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/core/autocommit/decorators.py#L111

Added line #L111 was not covered by tests
file_node_id, node_id = wrapped(*args, **kwargs)
instance.G._autocommit.set_pending(instance, node_id, file_node_id)
instance.ctx._autocommit.set_pending(instance, node_id, file_node_id)

Check warning on line 113 in src/codegen/sdk/core/autocommit/decorators.py

View check run for this annotation

Codecov / codecov/patch

src/codegen/sdk/core/autocommit/decorators.py#L113

Added line #L113 was not covered by tests
instance.removed = False
return None
Loading