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

Commit 4a6161f

Browse files
committed
Added test for pep257 backwards compatibility
1 parent 4e821f3 commit 4a6161f

File tree

3 files changed

+872
-870
lines changed

3 files changed

+872
-870
lines changed

src/pydocstyle.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def next(obj, default=nothing):
5656
tokenize_open = open
5757

5858

59-
__version__ = '0.7.1-alpha'
59+
__version__ = '1.0.0a0'
6060
__all__ = ('check',)
6161

6262
NO_VIOLATIONS_RETURN_CODE = 0
@@ -1052,9 +1052,10 @@ def _create_check_config(cls, options, use_dafaults=True):
10521052
return CheckConfiguration(checked_codes=checked_codes,
10531053
match=match, match_dir=match_dir)
10541054

1055-
def _get_section_name(parser):
1055+
@classmethod
1056+
def _get_section_name(cls, parser):
10561057
"""Parse options from relevant section."""
1057-
for section_name in POSSIBLE_SECTION_NAMES:
1058+
for section_name in cls.POSSIBLE_SECTION_NAMES:
10581059
if parser.has_section(section_name):
10591060
return section_name
10601061

@@ -1073,7 +1074,7 @@ def _get_config_file_in_folder(cls, path):
10731074
for fn in cls.PROJECT_CONFIG_FILES:
10741075
config = RawConfigParser()
10751076
full_path = os.path.join(path, fn)
1076-
if config.read(full_path) and self._get_section_name(config):
1077+
if config.read(full_path) and cls._get_section_name(config):
10771078
return full_path
10781079

10791080
@staticmethod
@@ -1271,9 +1272,7 @@ class StdoutFilter(logging.Filter):
12711272
def filter(self, record):
12721273
return record.levelno in (logging.DEBUG, logging.INFO)
12731274

1274-
if log.handlers:
1275-
for handler in log.handlers:
1276-
log.removeHandler(handler)
1275+
log.handlers = []
12771276

12781277
stdout_handler = logging.StreamHandler(sys.stdout)
12791278
stdout_handler.setLevel(logging.WARNING)
@@ -1307,9 +1306,9 @@ def run_pydocstyle(used_pep257=False):
13071306
setup_stream_handlers(run_conf)
13081307

13091308
if used_pep257:
1310-
log.warning("Deprecation Warning:"
1309+
log.warning("Deprecation Warning:\n"
13111310
"pep257 has been renamed to pydocstyle and the use of the "
1312-
"pep257 executable is deprecated and will be removed in"
1311+
"pep257 executable is deprecated and will be removed in "
13131312
"version 2.0.0. Please use pydocstyle instead.")
13141313

13151314
log.debug("starting in debug mode.")
@@ -1665,12 +1664,16 @@ def SKIP_check_return_type(self, function, docstring):
16651664
return Error()
16661665

16671666

1668-
def main():
1667+
def main(use_pep257=False):
16691668
try:
1670-
sys.exit(run_pydocstyle())
1669+
sys.exit(run_pydocstyle(use_pep257))
16711670
except KeyboardInterrupt:
16721671
pass
16731672

16741673

1674+
def main_pep257():
1675+
main(use_pep257=True)
1676+
1677+
16751678
if __name__ == '__main__':
16761679
main()

0 commit comments

Comments
 (0)