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

Commit 3f36d52

Browse files
committed
Added the new error code.
1 parent 51bfb1d commit 3f36d52

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pep257.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,11 @@ def parse_module(self):
402402
children = list(self.parse_definitions(Module, all=True))
403403
assert self.current is None, self.current
404404
end = self.line
405-
module = Module(self.filename, self.source, start, end,
406-
[], docstring, children, None, self.all)
405+
cls = Module
406+
if self.filename.endswith('__init__.py'):
407+
cls = Package
408+
module = cls(self.filename, self.source, start, end,
409+
[], docstring, children, None, self.all)
407410
for child in module.children:
408411
child.parent = module
409412
log.debug("finished parsing module.")
@@ -584,6 +587,7 @@ def to_rst(cls):
584587
D101 = D1xx.create_error('D101', 'Missing docstring in public class')
585588
D102 = D1xx.create_error('D102', 'Missing docstring in public method')
586589
D103 = D1xx.create_error('D103', 'Missing docstring in public function')
590+
D104 = D1xx.create_error('D104', 'Missing docstring in public package')
587591

588592
D2xx = ErrorRegistry.create_group('D2', 'Whitespace Issues')
589593
D200 = D2xx.create_error('D200', 'One-line docstring should fit on one line '
@@ -930,7 +934,8 @@ def check_docstring_missing(self, definition, docstring):
930934
if (not docstring and definition.is_public or
931935
docstring and is_blank(eval(docstring))):
932936
codes = {Module: D100, Class: D101, NestedClass: D101,
933-
Method: D102, Function: D103, NestedFunction: D103}
937+
Method: D102, Function: D103, NestedFunction: D103,
938+
Package: D104}
934939
return codes[type(definition)]()
935940

936941
@check_for(Definition)

0 commit comments

Comments
 (0)