Skip to content

Commit 4d3f02d

Browse files
humitosericholscher
authored andcommitted
Build: bugfix RepositoryError.CLONE_ERROR message
This commit converts the `@property` used to select the correct message depending on the platform (.org or .com) by a `@classmethod` to make it simpler to realize that we need to call it as a regular method. In Python 3.9, we will be able to combine these two decorators and we won't need parenthesis anymore. For now, we need to add parenthesis to make the call of the method.
1 parent df8599b commit 4d3f02d

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

readthedocs/projects/exceptions.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ class RepositoryError(BuildUserError):
5151
"Please check the command output for more information.",
5252
)
5353

54-
@property
55-
def CLONE_ERROR(self): # noqa: N802
54+
# NOTE: we are not using `@property` here because Python 3.8 does not
55+
# suport `@property` together with `@classmethod`. On Python >= 3.9, we
56+
# could call `RepositoryError.CLONE_ERROR` without parenthesis and it will
57+
# work. However, for now, we are just using a class method and calling it
58+
# as a function/method.
59+
@classmethod
60+
def CLONE_ERROR(cls): # noqa: N802
5661
if settings.ALLOW_PRIVATE_REPOS:
57-
return self.PRIVATE_ALLOWED
58-
return self.PRIVATE_NOT_ALLOWED
62+
return cls.PRIVATE_ALLOWED
63+
return cls.PRIVATE_NOT_ALLOWED
5964

6065
def get_default_message(self):
6166
return self.GENERIC_ERROR

readthedocs/vcs_support/backends/bzr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def clone(self):
3838
try:
3939
self.run("bzr", "checkout", self.repo_url, ".")
4040
except RepositoryError:
41-
raise RepositoryError(RepositoryError.CLONE_ERROR)
41+
raise RepositoryError(RepositoryError.CLONE_ERROR())
4242

4343
@property
4444
def tags(self):

readthedocs/vcs_support/backends/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def clone(self):
200200
code, stdout, stderr = self.run(*cmd)
201201
return code, stdout, stderr
202202
except RepositoryError:
203-
raise RepositoryError(RepositoryError.CLONE_ERROR)
203+
raise RepositoryError(RepositoryError.CLONE_ERROR())
204204

205205
@property
206206
def lsremote(self):

readthedocs/vcs_support/backends/hg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def clone(self):
4343
)
4444
return output
4545
except RepositoryError:
46-
raise RepositoryError(RepositoryError.CLONE_ERROR)
46+
raise RepositoryError(RepositoryError.CLONE_ERROR())
4747

4848
@property
4949
def branches(self):

readthedocs/vcs_support/backends/svn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def co(self, identifier=None):
6262
url = self.repo_url
6363
retcode, out, err = self.run('svn', 'checkout', url, '.')
6464
if retcode != 0:
65-
raise RepositoryError(RepositoryError.CLONE_ERROR)
65+
raise RepositoryError(RepositoryError.CLONE_ERROR())
6666
return retcode, out, err
6767

6868
@property

0 commit comments

Comments
 (0)