Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit b413c56

Browse files
committed
Put return codes in a class for namespacing
1 parent 4171679 commit b413c56

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/pydocstyle.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ def next(obj, default=nothing):
5959
__version__ = '1.0.1-rc1'
6060
__all__ = ('check',)
6161

62-
NO_VIOLATIONS_RETURN_CODE = 0
63-
VIOLATIONS_RETURN_CODE = 1
64-
INVALID_OPTIONS_RETURN_CODE = 2
62+
63+
class ReturnCode(object):
64+
no_violations_found = 0
65+
violations_found = 1
66+
invalid_options = 2
67+
68+
6569
VARIADIC_MAGIC_METHODS = ('__init__', '__call__', '__new__')
6670

6771

@@ -1297,7 +1301,7 @@ def run_pydocstyle(used_pep257=False):
12971301
try:
12981302
conf.parse()
12991303
except IllegalConfiguration:
1300-
return INVALID_OPTIONS_RETURN_CODE
1304+
return ReturnCode.invalid_options
13011305

13021306
run_conf = conf.get_user_run_configuration()
13031307

@@ -1321,13 +1325,13 @@ def run_pydocstyle(used_pep257=False):
13211325
errors.extend(check((filename,), select=checked_codes))
13221326
except IllegalConfiguration:
13231327
# An illegal configuration file was found during file generation.
1324-
return INVALID_OPTIONS_RETURN_CODE
1328+
return ReturnCode.invalid_options
13251329

1326-
code = NO_VIOLATIONS_RETURN_CODE
1330+
code = ReturnCode.no_violations_found
13271331
count = 0
13281332
for error in errors:
13291333
sys.stderr.write('%s\n' % error)
1330-
code = VIOLATIONS_RETURN_CODE
1334+
code = ReturnCode.violations_found
13311335
count += 1
13321336
if run_conf.count:
13331337
print(count)

0 commit comments

Comments
 (0)