Make sure consistently using one docstring style#4822
Conversation
The remaining files that have old-style or reST-style docstrings are switched to Google style. This does *not* remove the inline reST-style annotations for functions, classes, modules, etc. - that's a different topic, we want to keep those so API docs are generated with hyperlinks to the referenced element. Burying the lede... there was an actual bugfix here, in Defaults.py a copy-pasted chunk ended up with a reference to a variable that was not in scope at that point (in processDefines). Was glancing at Defaults.py in an IDE to see what it thought was broken, and it was red on that one... Some minor de-linting in Defaults.py and Node/FS.py, and fix an annotation error in FS (invalidate_node_memos) - of course that one has no runtime effect. Signed-off-by: Mats Wichmann <mats@linux.com>
testing/framework/TestCmd.py
Outdated
| lines: str | list | None = None, | ||
| matches: str | list | None = None, |
There was a problem hiding this comment.
| lines: str | list | None = None, | |
| matches: str | list | None = None, | |
| lines: str | list[str] | None = None, | |
| matches: str | list[str] | None = None, |
There was a problem hiding this comment.
Hmmm, this isn't going to work as annotated anyway... if lines is the default None, then:
if not is_List(lines):
lines = lines.split(newline)is going to throw an AttributeError cause None has no split method. The same for matches, for that matter. I'm thinking a default of an empty string is better?
testing/framework/TestCmd.py
Outdated
|
|
||
| def match_caseinsensitive(lines=None, matches=None): | ||
| def match_caseinsensitive( | ||
| lines: str | list | None = None, matches: str | list | None = None |
There was a problem hiding this comment.
| lines: str | list | None = None, matches: str | list | None = None | |
| lines: str | list[str] | None = None, matches: str | list[str] | None = None |
There was a problem hiding this comment.
Same problem as for match_exact
testing/framework/TestCmd.py
Outdated
|
|
||
|
|
||
| def match_re(lines=None, res=None): | ||
| def match_re(lines: str | list | None = None, res: str | list | None = None) -> int | None: |
There was a problem hiding this comment.
| def match_re(lines: str | list | None = None, res: str | list | None = None) -> int | None: | |
| def match_re( | |
| lines: str | list[str] | None = None, res: str | list[str] | None = None | |
| ) -> int | None: |
There was a problem hiding this comment.
Same problem as for match_exact
testing/framework/TestCmd.py
Outdated
|
|
||
| def match_re_dotall(lines=None, res=None): | ||
| def match_re_dotall( | ||
| lines: str | list | None = None, res: str | list | None = None |
There was a problem hiding this comment.
| lines: str | list | None = None, res: str | list | None = None | |
| lines: str | list[str] | None = None, res: str | list[str] | None = None |
testing/framework/TestCmd.py
Outdated
| do_chmod(top) | ||
|
|
||
| def write(self, file, content, mode: str = 'wb'): | ||
| def write(self, file: str | list, content: str | bytes, mode: str = 'wb'): |
There was a problem hiding this comment.
| def write(self, file: str | list, content: str | bytes, mode: str = 'wb'): | |
| def write(self, file: str | list[str], content: str | bytes, mode: str = 'wb'): |
Indeed. |
|
These look fine to me, @bdbaddog okay for the changes to be added? |
My type hints fu is weak. If they look good you, go ahead.. |
For the match functions that can take a list argument, annotate then as string-or-list-of-strings. (from review comment) Also the write method - the "filename" can be a list of strings (path components), annotate is as such as well. Signed-off-by: Mats Wichmann <mats@linux.com>
f29ab44 to
2e1acdf
Compare
|
So.. should we eliminate the |
…hanges in that file
The remaining files that have old-style aka reST-style docstrings are switched to Google style. This does not remove the inline reST-style annotations for functions, classes, modules, etc. - that's a different topic, we want to keep those so API docs are generated with hyperlinks to the referenced element.
In a bit of "burying the lede"... there was an actual bugfix here, in
Defaults.pya copy-pasted chunk ended up with a reference to a variable that was not in scope at that point (inprocessDefines). Was glancing atDefaults.pyin an IDE to see what it thought was broken, and it was red on that one.Some minor de-linting in
Defaults.pyandNode/FS.py, and fix an annotation error inFS.py(invalidate_node_memos) - of course that one has no runtime effect.This has no doc or test changes, it's nearly all docstrings, type annotations and moving imports - none of which have runtime effects.
Contributor Checklist:
CHANGES.txtandRELEASE.txt(and read theREADME.rst).