Skip to content

Commit 58614c1

Browse files
authored
Fix disable_file_parse for create_file (#819)
# 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
1 parent e2e4dfb commit 58614c1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/codegen/sdk/codebase/codebase_context.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ def build_graph(self, repo_operator: RepoOperator) -> None:
224224

225225
# =====[ Add all files to the graph in parallel ]=====
226226
syncs = defaultdict(lambda: [])
227-
if not self.config.disable_file_parse:
227+
if self.config.disable_file_parse:
228+
logger.warning("WARNING: File parsing is disabled!")
229+
else:
228230
for filepath, _ in repo_operator.iter_files(subdirs=self.projects[0].subdirectories, extensions=self.extensions, ignore_list=GLOBAL_FILE_IGNORE_LIST):
229231
syncs[SyncType.ADD].append(self.to_absolute(filepath))
230232
logger.info(f"> Parsing {len(syncs[SyncType.ADD])} files in {self.projects[0].subdirectories or 'ALL'} subdirectories with {self.extensions} extensions")
@@ -266,7 +268,9 @@ def apply_diffs(self, diff_list: list[DiffLite]) -> None:
266268
else:
267269
logger.warning(f"Unhandled diff change type: {diff.change_type}")
268270
by_sync_type = defaultdict(lambda: [])
269-
if not self.config.disable_file_parse:
271+
if self.config.disable_file_parse:
272+
logger.warning("WARNING: File parsing is disabled!")
273+
else:
270274
for filepath, sync_type in files_to_sync.items():
271275
if self.get_file(filepath) is None:
272276
if sync_type is SyncType.DELETE:

src/codegen/sdk/core/codebase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def create_file(self, filepath: str, content: str = "", sync: bool = True) -> TS
498498

499499
file_exts = self.ctx.extensions
500500
# Create file as source file if it has a registered extension
501-
if any(filepath.endswith(ext) for ext in file_exts):
501+
if any(filepath.endswith(ext) for ext in file_exts) and not self.ctx.config.disable_file_parse:
502502
file_cls = self.ctx.node_classes.file_cls
503503
file = file_cls.from_content(filepath, content, self.ctx, sync=sync)
504504
if file is None:

0 commit comments

Comments
 (0)