Skip to content

Commit cdb7659

Browse files
tomcodgentkfoss
andauthored
fix: [CG-10935] tests patch (#818)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed --------- Co-authored-by: tomcodgen <191515280+tomcodgen@users.noreply.github.com>
1 parent 4164602 commit cdb7659

File tree

13 files changed

+62
-8
lines changed

13 files changed

+62
-8
lines changed

src/codegen/sdk/core/function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def resolve_name(self, name: str, start_byte: int | None = None, strict: bool =
148148
if symbol.name == name and (start_byte is None or (symbol.start_byte if isinstance(symbol, Class | Function) else symbol.end_byte) <= start_byte):
149149
yield symbol
150150
return
151-
yield from super().resolve_name(name, start_byte)
151+
yield from super().resolve_name(name, start_byte, strict=strict)
152152

153153
@cached_property
154154
@noapidoc

src/codegen/sdk/core/interfaces/conditional_block.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22
from collections.abc import Sequence
33

44
from codegen.sdk.core.statements.statement import Statement
5+
from codegen.shared.decorators.docs import noapidoc
56

67

78
class ConditionalBlock(Statement, ABC):
89
"""An interface for any code block that might not be executed in the code, e.g if block/else block/try block/catch block ect."""
910

1011
@property
1112
@abstractmethod
13+
@noapidoc
1214
def other_possible_blocks(self) -> Sequence["ConditionalBlock"]:
1315
"""Should return all other "branches" that might be executed instead."""
1416

1517
@property
18+
@noapidoc
1619
def end_byte_for_condition_block(self) -> int:
20+
"""Returns the end byte for the specific condition block"""
1721
return self.end_byte

src/codegen/sdk/core/statements/for_loop_statement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ def resolve_name(self, name: str, start_byte: int | None = None, strict: bool =
5757
return
5858
yield frame.top.node
5959
return
60-
yield from super().resolve_name(name, start_byte)
60+
yield from super().resolve_name(name, start_byte, strict=strict)

src/codegen/sdk/core/statements/if_block_statement.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,10 @@ def reduce_condition(self, bool_condition: bool, node: Editable | None = None) -
276276
self.remove()
277277

278278
@property
279+
@noapidoc
279280
def other_possible_blocks(self) -> Sequence[ConditionalBlock]:
280281
if self.is_if_statement:
281-
return self._main_if_block.alternative_blocks
282+
return self.alternative_blocks
282283
elif self.is_elif_statement:
283284
main = self._main_if_block
284285
statements = [main]
@@ -293,6 +294,7 @@ def other_possible_blocks(self) -> Sequence[ConditionalBlock]:
293294
return [main, *main.elif_statements]
294295

295296
@property
297+
@noapidoc
296298
def end_byte_for_condition_block(self) -> int:
297299
if self.is_if_statement:
298300
return self.consequence_block.end_byte

src/codegen/sdk/core/statements/switch_case.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,7 @@ def _compute_dependencies(self, usage_type: UsageKind | None = None, dest: HasNa
3737
super()._compute_dependencies(usage_type, dest)
3838

3939
@property
40+
@noapidoc
4041
def other_possible_blocks(self) -> list[ConditionalBlock]:
42+
"""Returns the end byte for the specific condition block"""
4143
return [case for case in self.parent.cases if case != self]

src/codegen/sdk/python/function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def resolve_name(self, name: str, start_byte: int | None = None, strict: bool =
131131
if name == "super()":
132132
yield self.parent_class
133133
return
134-
yield from super().resolve_name(name, start_byte)
134+
yield from super().resolve_name(name, start_byte, strict=strict)
135135

136136
@noapidoc
137137
@commiter

src/codegen/sdk/python/statements/catch_statement.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from codegen.sdk.core.statements.catch_statement import CatchStatement
66
from codegen.sdk.python.detached_symbols.code_block import PyCodeBlock
77
from codegen.sdk.python.statements.block_statement import PyBlockStatement
8-
from codegen.shared.decorators.docs import py_apidoc
8+
from codegen.shared.decorators.docs import noapidoc, py_apidoc
99

1010
if TYPE_CHECKING:
1111
from tree_sitter import Node as PyNode
@@ -29,5 +29,6 @@ def __init__(self, ts_node: PyNode, file_node_id: NodeId, ctx: CodebaseContext,
2929
self.condition = self.children[0]
3030

3131
@property
32+
@noapidoc
3233
def other_possible_blocks(self) -> list[ConditionalBlock]:
3334
return [clause for clause in self.parent.except_clauses if clause != self] + [self.parent]

src/codegen/sdk/python/statements/match_case.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from codegen.sdk.core.statements.switch_case import SwitchCase
77
from codegen.sdk.python.detached_symbols.code_block import PyCodeBlock
88
from codegen.sdk.python.statements.block_statement import PyBlockStatement
9-
from codegen.shared.decorators.docs import py_apidoc
9+
from codegen.shared.decorators.docs import noapidoc, py_apidoc
1010

1111
if TYPE_CHECKING:
1212
from codegen.sdk.codebase.codebase_context import CodebaseContext
@@ -23,5 +23,6 @@ def __init__(self, ts_node: PyNode, file_node_id: NodeId, ctx: "CodebaseContext"
2323
self.condition = self.child_by_field_name("alternative")
2424

2525
@property
26+
@noapidoc
2627
def other_possible_blocks(self) -> list["ConditionalBlock"]:
2728
return [case for case in self.parent.cases if case != self]

src/codegen/sdk/python/statements/try_catch_statement.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ def nested_code_blocks(self) -> list[PyCodeBlock]:
101101
return nested_blocks
102102

103103
@property
104+
@noapidoc
104105
def other_possible_blocks(self) -> Sequence[ConditionalBlock]:
105106
return self.except_clauses
106107

107108
@property
109+
@noapidoc
108110
def end_byte_for_condition_block(self) -> int:
109111
if self.code_block:
110112
return self.code_block.end_byte

src/codegen/sdk/typescript/function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def resolve_name(self, name: str, start_byte: int | None = None, strict: bool =
378378
if name == "this":
379379
yield self.parent_class
380380
return
381-
yield from super().resolve_name(name, start_byte)
381+
yield from super().resolve_name(name, start_byte, strict=strict)
382382

383383
@staticmethod
384384
def is_valid_node(node: TSNode) -> bool:

0 commit comments

Comments
 (0)