-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MAINT: Changed class constructor __init__ GL08 reporting #592
Changes from 11 commits
bd64a7d
998d72f
a43b5b9
cc5fe97
ea2c5e3
3f51f53
66818ea
b22eb3b
be2bd62
296043d
e0edc18
b7eb310
de00113
abe64b2
8fb92b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -637,7 +637,23 @@ def validate(obj_name, validator_cls=None, **validator_kwargs): | |
|
||
errs = [] | ||
if not doc.raw_doc: | ||
if "GL08" not in ignore_validation_comments: | ||
report_GL08: bool = True | ||
# Check if the object is a class and has a docstring in the constructor | ||
if doc.name.endswith("__init__") and doc.is_function_or_method: | ||
mattgebert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cls_name = doc.code_obj.__qualname__.split(".")[0] | ||
cls = getattr(importlib.import_module(doc.code_obj.__module__), cls_name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @larsoner I don't know enough about current internals to know if this is how we do things; no utility functions / class methods for this purpose? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @larsoner I don't think the second one works;
Any preference? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either seems okay, hopefully they're equivalent! |
||
cls_doc = Validator(get_doc_object(cls)) | ||
|
||
# Parameter_mismatches, PR01, PR02, PR03 are checked for the class docstring. | ||
# If cls_doc has PR01, PR02, PR03 errors, i.e. invalid class docstring, | ||
# then we also report missing constructor docstring, GL08. | ||
report_GL08 = len(cls_doc.parameter_mismatches) > 0 | ||
|
||
# Check if GL08 is to be ignored: | ||
if "GL08" in ignore_validation_comments: | ||
report_GL08 = False | ||
# Add GL08 error? | ||
if report_GL08: | ||
errs.append(error("GL08")) | ||
return { | ||
"type": doc.type, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We recommended only the class docstring before. How do documentation writers decide what to put in the two docstrings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above my introductory pay grade, but I would stick to recommending class docstring only? The changes only allow flexibility for a constructor docstring if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes:
And all that :)