Skip to content
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
18 changes: 1 addition & 17 deletions src/graph_sitter/compiled/autocommit.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import functools
from collections.abc import Callable
from typing import Any, ParamSpec, TypeVar, Union, overload
from typing import Any, ParamSpec, TypeVar, Union

import wrapt

Expand All @@ -20,14 +20,6 @@ def is_outdated(c) -> bool:
return False


@overload
def reader(wrapped: Callable[P, T]) -> Callable[P, T]: ...


@overload
def reader(wrapped: None = None, *, cache: bool | None = ...) -> Callable[[Callable[P, T]], Callable[P, T]]: ...


def reader(wrapped: Callable[P, T] | None = None, *, cache: bool | None = None) -> Callable[P, T] | Callable[[Callable[P, T]], Callable[P, T]]:
"""Indicates this method is a read

Expand Down Expand Up @@ -176,14 +168,6 @@ def update_dict(seen: set["Editable"], obj: "Editable", new_obj: "Editable"):
assert not obj.is_outdated


@overload
def commiter(wrapped: Callable[P, T]) -> Callable[P, T]: ...


@overload
def commiter(wrapped: None = None, *, reset: bool = ...) -> Callable[[Callable[P, T]], Callable[P, T]]: ...


def commiter(wrapped: Callable[P, T] | None = None, *, reset: bool = False) -> Callable[P, T] | Callable[[Callable[P, T]], Callable[P, T]]:
"""Indicates this method is part of a commit. There should be no writes within this method and reads will not be updated

Expand Down
2 changes: 1 addition & 1 deletion src/graph_sitter/git/repo_operator/repo_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,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 145 in src/graph_sitter/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 = username or reader.get("user", "name")
user_level = user_level or level
Expand Down Expand Up @@ -170,8 +170,8 @@
try:
return self.git_cli.head.commit
except ValueError as e:
if (f"Reference at {self.git_cli.head.ref.path!r} does not exist") in str(e):

Check failure on line 173 in src/graph_sitter/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: "Callable[[], SymbolicReference]" has no attribute "path" [attr-defined]
logger.info(f"Ref: {self.git_cli.head.ref.name} has no commits")

Check failure on line 174 in src/graph_sitter/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: "Callable[[], SymbolicReference]" has no attribute "name" [attr-defined]
return None
raise

Expand Down Expand Up @@ -479,7 +479,7 @@

def _get_username_email(self) -> tuple[str, str] | None:
for level in ["user", "global", "system"]:
with self.git_cli.config_reader(level) as reader:

Check failure on line 482 in src/graph_sitter/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_section("user"):
user, email = reader.get_value("user", "name"), reader.get_value("user", "email")
if isinstance(user, str) and isinstance(email, str) and user != CODEGEN_BOT_NAME and email != CODEGEN_BOT_EMAIL:
Expand All @@ -488,7 +488,7 @@

def commit_changes(self, message: str, verify: bool = False) -> bool:
"""Returns True if a commit was made and False otherwise."""
staged_changes = self.git_cli.git.diff("--staged")
staged_changes = self.git_cli.git.diff("--no-ext-diff", "--staged")
if staged_changes:
if self.bot_commit and (info := self._get_username_email()):
user, email = info
Expand Down Expand Up @@ -580,7 +580,7 @@
return content
except UnicodeDecodeError:
print(f"Warning: Unable to decode file {file_path}. Skipping.")
return None

Check failure on line 583 in src/graph_sitter/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 @@ -652,7 +652,7 @@
filepaths = self.get_filepaths_for_repo(ignore_list)
# Iterate through files and yield contents
for rel_filepath in filepaths:
rel_filepath: str

Check failure on line 655 in src/graph_sitter/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

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

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

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

Check failure on line 692 in src/graph_sitter/git/repo_operator/repo_operator.py

View workflow job for this annotation

GitHub Actions / mypy

error: Name "rel_filepath" already defined on line 691 [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 @@ -713,7 +713,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 716 in src/graph_sitter/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 @@ -729,9 +729,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 732 in src/graph_sitter/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 734 in src/graph_sitter/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]

@cached_property
def base_url(self) -> str | None:
Expand Down
Loading