MCPcopy
hub / github.com/MinishLab/semble / Chunk

Class Chunk

src/semble/types.py:29–53  ·  view source on GitHub ↗

A single indexable unit of code.

Source from the content-addressed store, hash-verified

27
28@dataclass(frozen=True, slots=True)
29class Chunk:
30 """A single indexable unit of code."""
31
32 content: str
33 file_path: str
34 start_line: int
35 end_line: int
36 language: str | None = None
37
38 @property
39 def location(self) -> str:
40 """File path and line range as a string."""
41 return f"{self.file_path}:{self.start_line}-{self.end_line}"
42
43 def to_dict(self) -> dict[str, Any]:
44 """Convert the dataclass to a dict."""
45 d = asdict(self)
46 d["location"] = self.location
47 return d
48
49 @classmethod
50 def from_dict(cls: type[Chunk], data: dict[str, Any]) -> Chunk:
51 """Create a Chunk from a dict."""
52 data.pop("location", None)
53 return cls(**data)
54
55
56@dataclass(frozen=True, slots=True)

Callers 5

chunk_sourceFunction · 0.90
make_chunkFunction · 0.90
_grep_file_unitsFunction · 0.90

Calls

no outgoing calls

Tested by 2

make_chunkFunction · 0.72