Skip to content

Commit f5fab1d

Browse files
Fix additional type checking issues
- Fix return type in get_file method to return empty string instead of None - Add type ignore for telemetry shutdown method - Add type ignore for decode method on bytes object - Fix create_pr_comment to raise exception instead of implicit None return - Handle None values in repo config path and language fields These fixes address several type checking diagnostics to improve code quality.
1 parent a6a9a76 commit f5fab1d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/codegen/cli/telemetry/otel_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def shutdown_otel_logging():
294294
try:
295295
# Type checker workaround: assert that provider is not None after the check
296296
assert _logger_provider is not None
297-
_logger_provider.shutdown()
297+
_logger_provider.shutdown() # type: ignore[possibly-unbound-attribute]
298298
except Exception:
299299
pass # Ignore shutdown errors
300300
_logger_provider = None

src/codegen/git/repo_operator/repo_operator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def get_file(self, path: str) -> str:
580580
return content
581581
except UnicodeDecodeError:
582582
print(f"Warning: Unable to decode file {file_path}. Skipping.")
583-
return None
583+
return ""
584584

585585
def write_file(self, relpath: str, content: str) -> None:
586586
"""Writes file content to disk"""
@@ -621,7 +621,7 @@ def get_filepaths_for_repo(self, ignore_list):
621621
decoded_filepath, _ = codecs.escape_decode(raw_filepath)
622622

623623
# Step 4: Decode those bytes as UTF-8 to get the actual Unicode text
624-
filepath = decoded_filepath.decode("utf-8")
624+
filepath = decoded_filepath.decode("utf-8") # type: ignore[unresolved-attribute]
625625

626626
# Step 5: Replace the original filepath with the decoded filepath
627627
filepaths[i] = filepath
@@ -765,6 +765,9 @@ def create_pr_comment(self, pr_number: int, body: str) -> IssueComment:
765765
if pr:
766766
comment = self.remote_git_repo.create_issue_comment(pr, body)
767767
return comment
768+
else:
769+
msg = f"PR {pr_number} not found"
770+
raise ValueError(msg)
768771

769772
def create_pr_review_comment(
770773
self,

src/codegen/git/schemas/repo_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def from_envs(cls) -> "RepoConfig":
3434
return RepoConfig(
3535
name=default_repo_config.name,
3636
full_name=default_repo_config.full_name,
37-
base_dir=os.path.dirname(default_repo_config.path),
38-
language=ProgrammingLanguage(default_repo_config.language.upper()),
37+
base_dir=os.path.dirname(default_repo_config.path or ""),
38+
language=ProgrammingLanguage((default_repo_config.language or "").upper()),
3939
)
4040

4141
@classmethod

0 commit comments

Comments
 (0)