Skip to content

Commit 8925df3

Browse files
committed
Merge remote-tracking branch 'refs/remotes/PyCQA/master' into numpy-conventions
# Conflicts: # src/pydocstyle.py # src/tests/test_definitions.py
2 parents 01f8ac4 + ae52b07 commit 8925df3

39 files changed

+2775
-2123
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ docs/_*
4343

4444
# virtualenv
4545
venv/
46+
.venvs/
4647

4748
# generated rst
4849
docs/snippets/error_code_table.rst

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ install: pip install tox
99
script: tox
1010
matrix:
1111
include:
12-
- python: 2.6
13-
env: TOXENV=py26
1412
- python: 2.7
1513
env: TOXENV=py27
1614
- python: 3.3
@@ -21,7 +19,5 @@ matrix:
2119
env: TOXENV=py35
2220
- python: pypy
2321
env: TOXENV=pypy
24-
- python: pypy3
25-
env: TOXENV=pypy3
2622
- python: 2.7
2723
env: TOXENV=docs

README.rst

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ docstring conventions.
1010
`PEP 257 <http://www.python.org/dev/peps/pep-0257/>`_ out of the box, but it
1111
should not be considered a reference implementation.
1212

13-
The framework for checking docstring style is flexible, and
14-
custom checks can be easily added, for example to cover
15-
NumPy `docstring conventions
16-
<https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt>`_.
17-
18-
**pydocstyle** supports Python 2.6, 2.7, 3.3, 3.4, 3.5, pypy and pypy3.
13+
**pydocstyle** supports Python 2.7, 3.3, 3.4, 3.5 and pypy.
1914

2015
Quick Start
2116
-----------
@@ -27,16 +22,19 @@ Install
2722
2823
pip install pydocstyle
2924
25+
3026
Run
31-
^^^
27+
^^^^
3228

3329
.. code::
3430
3531
$ pydocstyle test.py
3632
test.py:18 in private nested class `meta`:
3733
D101: Docstring missing
38-
test.py:22 in public method `method`:
39-
D102: Docstring missing
34+
test.py:27 in public function `get_user`:
35+
D300: Use """triple double quotes""" (found '''-quotes)
36+
test:75 in public function `init_database`:
37+
D201: No blank lines allowed before function docstring (found 1)
4038
...
4139
4240
@@ -50,7 +48,7 @@ Links
5048
:target: https://readthedocs.org/projects/pydocstyle/?badge=latest
5149
:alt: Documentation Status
5250

53-
* `Read the full documentation here <http://pydocstyle.readthedocs.org>`_.
51+
* `Read the full documentation here <http://pydocstyle.org>`_.
5452

5553
* `Fork pydocstyle on GitHub <http://github.com/PyCQA/pydocstyle>`_.
5654

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# If extensions (or modules to document with autodoc) are in another directory,
1919
# add these directories to sys.path here. If the directory is relative to the
2020
# documentation root, use os.path.abspath to make it absolute, like shown here.
21-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
21+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
2222

2323
# -- General configuration ------------------------------------------------
2424

@@ -268,7 +268,7 @@
268268

269269

270270
def generate_error_code_table():
271-
from pydocstyle import ErrorRegistry
271+
from pydocstyle.violations import ErrorRegistry
272272
with open(os.path.join('snippets', 'error_code_table.rst'), 'wt') as outf:
273273
outf.write(ErrorRegistry.to_rst())
274274

docs/error_codes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ check only error codes that are part of the `PEP257
1616

1717
All of the above error codes are checked for by default except for D203,
1818
D212, D213 and D404.
19+
20+
21+
Publicity
22+
---------
23+
24+
.. include:: snippets/publicity.rst

docs/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
pydocstyle's documentation
22
==========================
33

4-
(formerly pep257)
5-
64
**pydocstyle** is a static analysis tool for checking compliance with Python
75
docstring conventions.
86

97
**pydocstyle** supports most of
108
`PEP 257 <http://www.python.org/dev/peps/pep-0257/>`_ out of the box, but it
119
should not be considered a reference implementation.
1210

11+
**pydocstyle** supports Python 2.7, 3.3, 3.4, 3.5 and pypy.
12+
1313

1414
.. include:: quickstart.rst
1515

docs/quickstart.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ Quick Start
1414
$ pydocstyle test.py
1515
test.py:18 in private nested class `meta`:
1616
D101: Docstring missing
17-
test.py:22 in public method `method`:
18-
D102: Docstring missing
17+
test.py:27 in public function `get_user`:
18+
D300: Use """triple double quotes""" (found '''-quotes)
19+
test:75 in public function `init_database`:
20+
D201: No blank lines allowed before function docstring (found 1)
1921
...
2022
2123
3. Fix your code :)

docs/release_notes.rst

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,75 @@ Release Notes
77
Current Development Version
88
---------------------------
99

10+
Major Updates
11+
12+
* Support for Python 2.6 has been dropped (#206, #217).
13+
* Support for PyPy3 has been temporarily dropped, until it will be
14+
equivalent to CPython 3.3+ and supported by ``pip`` (#223).
15+
* Support for the ``pep257`` console script has been dropped. Only the
16+
``pydocstyle`` console script should be used (#216, #218).
17+
18+
New Features
19+
20+
* Decorator-based skipping via ``--ignore-decorators`` has been added (#204).
21+
* Support for using pycodestyle style wildcards has been added (#72, #209).
22+
* Superfluous opening quotes are now reported as part of D300 (#166, #225).
23+
24+
Bug Fixes
25+
26+
* Made parser more robust to bad source files (#168, #214)
27+
* Modules are now considered private if their name starts with a single
28+
underscore. This is a bugfix where "public module" (D100) was reported
29+
regardless of module name (#199, #222).
30+
31+
32+
1.1.1 - October 4th, 2016
33+
-------------------------
34+
35+
Bug Fixes
36+
37+
* Fixed an issue where the ``flake8-docstrings`` failed when accessing some
38+
public API from ``pydocstyle``.
39+
40+
41+
1.1.0 - September 29th, 2016
42+
----------------------------
43+
44+
Major Updates
45+
46+
* ``pydocstyle`` is no longer a single file. This might make it difficult for
47+
some users to just add it to their project, but the project has reached
48+
certain complexity where splitting it into modules was necessary (#200).
49+
1050
New Features
1151

1252
* Added the optional error codes D212 and D213, for checking whether
1353
the summary of a multi-line docstring starts at the first line,
1454
respectively at the second line (#174).
1555

16-
* Added D404 - First word of the docstring should not be `This`. It is turned
56+
* Added D404 - First word of the docstring should not be "This". It is turned
1757
off by default (#183).
1858

59+
* Added the ability to ignore specific function and method docstrings with
60+
inline comments:
61+
62+
1. "# noqa" skips all checks.
63+
64+
2. "# noqa: D102,D203" can be used to skip specific checks.
65+
1966
Bug Fixes
2067

68+
* Fixed an issue where file paths were printed in lower case (#179, #181).
69+
2170
* The error code D300 is now also being reported if a docstring has
2271
uppercase literals (``R`` or ``U``) as prefix (#176).
2372

73+
* Fixed a bug where an ``__all__`` error was reported when ``__all__`` was
74+
imported from another module with a different name (#182, #187).
75+
76+
* Fixed a bug where ``raise X from Y`` syntax caused ``pydocstyle`` to crash
77+
(#196, #200).
78+
2479
1.0.0 - January 30th, 2016
2580
--------------------------
2681

docs/snippets/cli.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ Usage
1717
--count print total number of errors to stdout
1818
--select=<codes> choose the basic list of checked errors by specifying
1919
which errors to check for (with a list of comma-
20-
separated error codes). for example:
21-
--select=D101,D202
20+
separated error codes or prefixes). for example:
21+
--select=D101,D2
2222
--ignore=<codes> choose the basic list of checked errors by specifying
2323
which errors to ignore (with a list of comma-separated
24-
error codes). for example: --ignore=D101,D202
24+
error codes or prefixes). for example:
25+
--ignore=D101,D2
2526
--convention=<name> choose the basic list of checked errors by specifying
2627
an existing convention. Possible conventions: pep257
2728
--add-select=<codes> amend the list of errors to check for by specifying
@@ -36,7 +37,20 @@ Usage
3637
search only dirs that exactly match <pattern> regular
3738
expression; default is --match-dir='[^\.].*', which
3839
matches all dirs that don't start with a dot
40+
--ignore-decorators=<decorators>
41+
ignore any functions or methods that are decorated by
42+
a function with a name fitting the <decorators>
43+
regular expression; default is --ignore-decorators=''
44+
which does not ignore any decorated functions.
3945
46+
.. note::
47+
48+
When using any of the ``--select``, ``--ignore``, ``--add-select``, or
49+
``--add-ignore`` command line flags, it is possible to pass a prefix for an
50+
error code. It will be expanded so that any code begining with that prefix
51+
will match. For example, running the command ``pydocstyle --ignore=D4``
52+
will ignore all docstring content issues as their error codes begining with
53+
"D4" (i.e. D400, D401, D402, D403, and D404).
4054

4155
Return Code
4256
^^^^^^^^^^^

docs/snippets/config.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Available options are:
3232
* ``add_ignore``
3333
* ``match``
3434
* ``match_dir``
35+
* ``ignore_decorators``
3536

3637
See the :ref:`cli_usage` section for more information.
3738

docs/snippets/in_file.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
``pydocstyle`` supports inline commenting to skip specific checks on
2+
specific functions or methods. The supported comments that can be added are:
3+
4+
1. ``"# noqa"`` skips all checks.
5+
6+
2. ``"# noqa: D102,D203"`` can be used to skip specific checks. Note that
7+
this is compatible with skips from `flake8 <http://flake8.pycqa.org/>`_,
8+
e.g. ``# noqa: D102,E501,D203``.
9+
10+
For example, this will skip the check for a period at the end of a function
11+
docstring::
12+
13+
>>> def bad_function(): # noqa: D400
14+
... """Omit a period in the docstring as an exception"""
15+
... pass

docs/snippets/publicity.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
The D1xx group of errors deals with missing docstring in public constructs:
2+
modules, classes, methods, etc. It is important to note how publicity is
3+
determined and what its effects are.
4+
5+
6+
How publicity is determined
7+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
8+
9+
Publicity for all constructs is determined as follows: a construct is
10+
considered *public* if -
11+
12+
1. Its immediate parent is public *and*
13+
2. Its name does not contain a single leading underscore.
14+
15+
A construct's immediate parent is the construct that contains it. For example,
16+
a method's parent is a class object. A class' parent is usually a module, but
17+
might also be a function, method, etc. A module can either have no parent, or
18+
it can have a parent that is a package.
19+
20+
In order for a construct to be considered public, its immediate parent must
21+
also be public. Since this definition is recursive, it means that *all* of its
22+
parents need to be public. The corollary is that if a construct is considered
23+
private, then all of its descendants are also considered private. For example,
24+
a class called ``_Foo`` is considered private. A method ``bar`` in ``_Foo`` is
25+
also considered private since its parent is a private class, even though its
26+
name does not begin with a single underscore.
27+
28+
29+
How publicity affects error reports
30+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31+
32+
The immediate effect of a construct being determined as private is that no
33+
D1xx errors will be reported for it (or its children, as the previous section
34+
explains). A private method, for instance, will not generate a D102 error, even
35+
if it has no docstring.
36+
37+
However, it is important to note that while docstring are optional for private
38+
construct, they are still required to adhere to your style guide. So if a
39+
private module `_foo.py` does not have a docstring, it will not generate a
40+
D100 error, but if it *does* have a docstring, that docstring might generate
41+
other errors.

docs/usage.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ Configuration Files
1717
^^^^^^^^^^^^^^^^^^^
1818

1919
.. include:: snippets/config.rst
20+
21+
22+
In-file configuration
23+
^^^^^^^^^^^^^^^^^^^^^
24+
25+
.. include:: snippets/in_file.rst

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
-r requirements/docs.txt
22
-r requirements/tests.txt
3+
-r requirements/test_env.txt
4+
-r requirements/runtime.txt

requirements/runtime.txt

Whitespace-only changes.

requirements/test_env.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tox

requirements/tests.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pytest==2.7.3
2-
pytest-pep8
3-
mock
4-
tox
1+
pytest==3.0.2
2+
pytest-pep8==1.0.6
3+
mock==2.0.0
4+
pathlib

setup.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1+
[bumpversion]
2+
current_version = 2.0.0rc
3+
commit = True
4+
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>.*))?
5+
serialize =
6+
{major}.{minor}.{patch}{release}
7+
{major}.{minor}.{patch}
8+
19
[wheel]
210
universal = 1
11+
12+
[bumpversion:part:release]
13+
optional_value = production
14+
values =
15+
rc
16+
production
17+
18+
[bumpversion:file:src/pydocstyle/utils.py]
19+

setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from setuptools import setup
44

55

6-
with open(os.path.join('src', 'pydocstyle.py')) as f:
6+
this_dir = os.path.dirname(__file__)
7+
8+
with open(os.path.join(this_dir, 'src', 'pydocstyle', 'utils.py')) as f:
79
for line in f:
810
if line.startswith('__version__'):
911
version = eval(line.split('=')[-1])
@@ -27,12 +29,11 @@
2729
'License :: OSI Approved :: MIT License',
2830
],
2931
keywords='pydocstyle, PEP 257, pep257, PEP 8, pep8, docstrings',
32+
packages=('pydocstyle',),
3033
package_dir={'': 'src'},
31-
py_modules=['pydocstyle'],
3234
entry_points={
3335
'console_scripts': [
34-
'pydocstyle = pydocstyle:main',
35-
'pep257 = pydocstyle:main_pep257',
36+
'pydocstyle = pydocstyle.cli:main',
3637
],
3738
},
3839
)

0 commit comments

Comments
 (0)