Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Collect files to be tested in the same way as pydocstyle (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
henry0312 committed Dec 27, 2017
1 parent 38d13ef commit dc97803
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pytest_docstyle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import logging

import pydocstyle
Expand All @@ -8,17 +9,25 @@ def pytest_addoption(parser):
group = parser.getgroup('docstyle')
group.addoption('--docstyle', action='store_true',
default=False, help='run pydocstyle')

# https://github.com/PyCQA/pydocstyle/blob/2.1.1/src/pydocstyle/config.py#L69
DEFAULT_MATCH_RE = pydocstyle.config.ConfigurationParser.DEFAULT_MATCH_RE + '$'

parser.addini('docstyle_convention', default='pep257',
help='choose the basic list of error codes to be checked (default: pep257)')
parser.addini('docstyle_add_select', type='args',
help='add error codes')
parser.addini('docstyle_add_ignore', type='args',
help='ignore error codes')
parser.addini('docstyle_match', default=DEFAULT_MATCH_RE,
help=f"check only files that exactly match regular expression (default: {DEFAULT_MATCH_RE})")


def pytest_collect_file(parent, path):
config = parent.config
if config.option.docstyle and path.ext == '.py':
if (config.option.docstyle and path.ext == '.py' \
# https://github.com/PyCQA/pydocstyle/blob/2.1.1/src/pydocstyle/config.py#L163
and re.match(config.getini('docstyle_match'), path.basename)):
return Item(path, parent)


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='pytest-docstyle',
version='1.1.0',
version='1.2.0',
description='pytest plugin to run pydocstyle',
url='https://github.com/henry0312/pytest-docstyle',
author='Tsukasa OMOTO',
Expand Down

0 comments on commit dc97803

Please sign in to comment.