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

Commit 76e4c56

Browse files
committed
Added docs and release notes.
1 parent bfe62e4 commit 76e4c56

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

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/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ New Features
2121
Bug Fixes
2222

2323
* Made parser more robust to bad source files (#168, #214)
24+
* Modules are now considered private if their name starts with a single
25+
underscore. This is a bugfix where "public module" (D100) was reported
26+
regardless of module name (#199, #222).
2427

2528
1.1.1 - October 4th, 2016
2629
-------------------------

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.

0 commit comments

Comments
 (0)