Skip to content

Commit 69b4bfc

Browse files
committed
Replace fields with properties
1 parent 411a8fd commit 69b4bfc

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/git_autograder/repo/null_repo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,31 @@
88

99

1010
class NullGitAutograderRepo(GitAutograderRepoBase):
11+
@property
1112
def repo(self) -> Repo:
1213
raise AttributeError(
1314
"Cannot access attribute repo on NullGitAutograderRepo. Check that your repo_type is not 'ignore'."
1415
)
1516

17+
@property
1618
def branches(self) -> BranchHelper:
1719
raise AttributeError(
1820
"Cannot access attribute branches on NullGitAutograderRepo. Check that your repo_type is not 'ignore'."
1921
)
2022

23+
@property
2124
def commits(self) -> CommitHelper:
2225
raise AttributeError(
2326
"Cannot access attribute commits on NullGitAutograderRepo. Check that your repo_type is not 'ignore'."
2427
)
2528

29+
@property
2630
def remotes(self) -> RemoteHelper:
2731
raise AttributeError(
2832
"Cannot access attribute remotes on NullGitAutograderRepo. Check that your repo_type is not 'ignore'."
2933
)
3034

35+
@property
3136
def files(self) -> FileHelper:
3237
raise AttributeError(
3338
"Cannot access attribute files on NullGitAutograderRepo. Check that your repo_type is not 'ignore'."

src/git_autograder/repo/repo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,22 @@ def __init__(
2525
self._remotes: RemoteHelper = RemoteHelper(self._repo)
2626
self._files: FileHelper = FileHelper(self._repo)
2727

28+
@property
2829
def repo(self) -> Repo:
2930
return self._repo
3031

32+
@property
3133
def branches(self) -> BranchHelper:
3234
return self._branches
3335

36+
@property
3437
def commits(self) -> CommitHelper:
3538
return self._commits
3639

40+
@property
3741
def remotes(self) -> RemoteHelper:
3842
return self._remotes
3943

44+
@property
4045
def files(self) -> FileHelper:
4146
return self._files

src/git_autograder/repo/repo_base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from abc import ABC, abstractmethod
1+
from abc import ABC, abstractmethod, abstractproperty
22

33
from git import Repo
44

@@ -9,17 +9,22 @@
99

1010

1111
class GitAutograderRepoBase(ABC):
12+
@property
1213
@abstractmethod
1314
def repo(self) -> Repo: ...
1415

16+
@property
1517
@abstractmethod
1618
def branches(self) -> BranchHelper: ...
1719

20+
@property
1821
@abstractmethod
1922
def commits(self) -> CommitHelper: ...
2023

24+
@property
2125
@abstractmethod
2226
def remotes(self) -> RemoteHelper: ...
2327

28+
@property
2429
@abstractmethod
2530
def files(self) -> FileHelper: ...

0 commit comments

Comments
 (0)