Skip to content

chore: Remove access token from local repo operator #354

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 1 commit into from
Feb 7, 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: 3 additions & 1 deletion src/codegen/git/repo_operator/remote_repo_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
"""A wrapper around GitPython to make it easier to interact with a cloned lowside repo."""

# __init__ attributes
repo_config: RepoConfig

Check failure on line 27 in src/codegen/git/repo_operator/remote_repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible types in assignment (expression has type "RepoConfig", base class "RepoOperator" defined the type as "BaseRepoConfig") [assignment]
base_dir: str
access_token: str | None = None

# lazy attributes
_remote_git_repo: GitRepoClient | None = None
Expand All @@ -42,7 +43,8 @@
bot_commit: bool = True,
access_token: str | None = None,
) -> None:
super().__init__(repo_config=repo_config, base_dir=base_dir, bot_commit=bot_commit, access_token=access_token)
super().__init__(repo_config=repo_config, base_dir=base_dir, bot_commit=bot_commit)

Check failure on line 46 in src/codegen/git/repo_operator/remote_repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument "repo_config" to "__init__" of "RepoOperator" has incompatible type "RepoConfig"; expected "BaseRepoConfig" [arg-type]
self.access_token = access_token
self.setup_repo_dir(setup_option=setup_option, shallow=shallow)

####################################################################################################################
Expand Down
3 changes: 0 additions & 3 deletions src/codegen/git/repo_operator/repo_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
repo_config: BaseRepoConfig
base_dir: str
bot_commit: bool = True
access_token: str | None = None
_codeowners_parser: CodeOwnersParser | None = None
_default_branch: str | None = None

Expand All @@ -38,13 +37,11 @@
repo_config: BaseRepoConfig,
base_dir: str = "/tmp",
bot_commit: bool = True,
access_token: str | None = None,
) -> None:
assert repo_config is not None
self.repo_config = repo_config
self.base_dir = base_dir
self.bot_commit = bot_commit
self.access_token = access_token

####################################################################################################################
# PROPERTIES
Expand All @@ -60,7 +57,7 @@

@property
def clone_url(self) -> str:
return f"https://github.com/{self.repo_config.full_name}.git"

Check failure on line 60 in src/codegen/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: "BaseRepoConfig" has no attribute "full_name" [attr-defined]

@property
def viz_path(self) -> str:
Expand Down Expand Up @@ -101,7 +98,7 @@
email_level = None
levels = ["system", "global", "user", "repository"]
for level in levels:
with git_cli.config_reader(level) as reader:

Check failure on line 101 in src/codegen/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument 1 to "config_reader" of "Repo" has incompatible type "str"; expected "Literal['system', 'global', 'user', 'repository'] | None" [arg-type]
if reader.has_option("user", "name") and not username:
username = reader.get("user", "name")
user_level = level
Expand Down Expand Up @@ -452,7 +449,7 @@
return content
except UnicodeDecodeError:
print(f"Warning: Unable to decode file {file_path}. Skipping.")
return None

Check failure on line 452 in src/codegen/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible return value type (got "None", expected "str") [return-value]

def write_file(self, relpath: str, content: str) -> None:
"""Writes file content to disk"""
Expand Down Expand Up @@ -497,7 +494,7 @@

# Iterate through files and yield contents
for rel_filepath in filepaths:
rel_filepath: str

Check failure on line 497 in src/codegen/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: Name "rel_filepath" already defined on line 496 [no-redef]
filepath = os.path.join(self.repo_path, rel_filepath)

# Filter by subdirectory (includes full filenames)
Expand Down Expand Up @@ -528,7 +525,7 @@
list_files = []

for rel_filepath in self.git_cli.git.ls_files().split("\n"):
rel_filepath: str

Check failure on line 528 in src/codegen/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: Name "rel_filepath" already defined on line 527 [no-redef]
if subdirs and not any(d in rel_filepath for d in subdirs):
continue
if extensions is None or any(rel_filepath.endswith(e) for e in extensions):
Expand All @@ -552,7 +549,7 @@

def get_modified_files_in_last_n_days(self, days: int = 1) -> tuple[list[str], list[str]]:
"""Returns a list of files modified and deleted in the last n days"""
modified_files = []

Check failure on line 552 in src/codegen/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: Need type annotation for "modified_files" (hint: "modified_files: list[<type>] = ...") [var-annotated]
deleted_files = []
allowed_extensions = [".py"]

Expand All @@ -568,9 +565,9 @@
if file in modified_files:
modified_files.remove(file)
else:
if file not in modified_files and file[-3:] in allowed_extensions:

Check failure on line 568 in src/codegen/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: Value of type "str | PathLike[str]" is not indexable [index]
modified_files.append(file)
return modified_files, deleted_files

Check failure on line 570 in src/codegen/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible return value type (got "tuple[list[str | PathLike[str]], list[str | PathLike[str]]]", expected "tuple[list[str], list[str]]") [return-value]

@abstractmethod
def base_url(self) -> str | None: ...
Expand Down