Skip to content

Comments

Make sure consistently using one docstring style#4822

Merged
bdbaddog merged 3 commits intoSCons:masterfrom
mwichmann:maint/docstring-gs
Feb 9, 2026
Merged

Make sure consistently using one docstring style#4822
bdbaddog merged 3 commits intoSCons:masterfrom
mwichmann:maint/docstring-gs

Conversation

@mwichmann
Copy link
Collaborator

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.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.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:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt and RELEASE.txt (and read the README.rst).
  • I have updated the appropriate documentation

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>
@mwichmann mwichmann added documentation maintenance Tasks to maintain internal SCons code/tools labels Jan 28, 2026
Copy link
Contributor

@Repiteo Repiteo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The returning None on failure, 1 on success. makes my heart ache, but I understand this is a non-functional pass. However, seeing as you are updating the type hints, the container types should be explicit

Comment on lines 555 to 556
lines: str | list | None = None,
matches: str | list | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lines: str | list | None = None,
matches: str | list | None = None,
lines: str | list[str] | None = None,
matches: str | list[str] | None = None,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?


def match_caseinsensitive(lines=None, matches=None):
def match_caseinsensitive(
lines: str | list | None = None, matches: str | list | None = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lines: str | list | None = None, matches: str | list | None = None
lines: str | list[str] | None = None, matches: str | list[str] | None = None

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem as for match_exact



def match_re(lines=None, res=None):
def match_re(lines: str | list | None = None, res: str | list | None = None) -> int | None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem as for match_exact


def match_re_dotall(lines=None, res=None):
def match_re_dotall(
lines: str | list | None = None, res: str | list | None = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lines: str | list | None = None, res: str | list | None = None
lines: str | list[str] | None = None, res: str | list[str] | None = None

do_chmod(top)

def write(self, file, content, mode: str = 'wb'):
def write(self, file: str | list, content: str | bytes, mode: str = 'wb'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'):

@mwichmann
Copy link
Collaborator Author

The returning None on failure, 1 on success. makes my heart ache

Indeed.

@mwichmann
Copy link
Collaborator Author

These look fine to me, @bdbaddog okay for the changes to be added?

@bdbaddog
Copy link
Contributor

bdbaddog commented Feb 2, 2026

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>
@mwichmann
Copy link
Collaborator Author

So.. should we eliminate the None type option and None default for the observed and expected arguments to the four match functions? As mentioned above, they will raise an exception if None actually made it through as an argument value, nor do they make any actual sense - how can you call a function to compare two strings or lists of string (or regex strings) if one or both aren't even supplied?

@bdbaddog bdbaddog merged commit 50697c6 into SCons:master Feb 9, 2026
10 of 11 checks passed
@mwichmann mwichmann added this to the NextRelease milestone Feb 9, 2026
@mwichmann mwichmann deleted the maint/docstring-gs branch February 9, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation maintenance Tasks to maintain internal SCons code/tools

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants