Skip to content

Commit c377c48

Browse files
committed
codingstyle: collapse _CommandResult desc building
1 parent fb3417c commit c377c48

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/pkgcheck/checks/codingstyle.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,22 @@ def __init__(self, command, line, lineno, **kwargs):
9696
self.line = line
9797
self.lineno = lineno
9898

99-
100-
class PortageInternals(_CommandResult, base.Error):
101-
"""Ebuild uses a function or variable internal to portage."""
99+
@property
100+
def usage_desc(self):
101+
return f'{self.command!r}'
102102

103103
@property
104104
def desc(self):
105-
s = f'{self.command!r}, used on line {self.lineno}'
105+
s = f'{self.usage_desc}, used on line {self.lineno}'
106106
if self.line != self.command:
107107
s += f': {self.line!r}'
108108
return s
109109

110110

111+
class PortageInternals(_CommandResult, base.Error):
112+
"""Ebuild uses a function or variable internal to portage."""
113+
114+
111115
class _EapiCommandResult(_CommandResult):
112116
"""Generic EAPI command result."""
113117

@@ -116,11 +120,8 @@ def __init__(self, *args, eapi, **kwargs):
116120
self.eapi = eapi
117121

118122
@property
119-
def desc(self):
120-
s = f'{self.command!r} {self._status} in EAPI {self.eapi}, used on line {self.lineno}'
121-
if self.line != self.command:
122-
s += f': {self.line!r}'
123-
return s
123+
def usage_desc(self):
124+
return f'{self.command!r} {self._status} in EAPI {self.eapi}'
124125

125126

126127
class DeprecatedEapiCommand(_EapiCommandResult, base.Warning):

0 commit comments

Comments
 (0)