-
Notifications
You must be signed in to change notification settings - Fork 2.8k
docs: fix module docstrings and copyright headers #2077
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
Conversation
@@ -1,17 +1,16 @@ | |||
""" |
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.
I don't think this change is effective, please keep it as it is.
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.
Could you elaborate more about what the word "effective" means?
If the module do not have a docstring, the __doc__
attribute should be None
instead of a copyright string.
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.
Hi @XuehaiPan I just realized I didn't look carefully before. Thank you for your reply. Changing """ to # is reasonable. Could you send another PR? Thanks!
Thanks anyway! |
It's OK for me if you do not want the project to be maintained under a higher code standard. lol 🤷♂️ |
@zhyncs why do you reject this PR? |
@XuehaiPan Can you share your scripts to do these changes? |
#!/usr/bin/env python3
import re
import subprocess
from pathlib import Path
GIT_DEFAULT_BRANCH = "main"
GIT_TRACKED_FILES = list(
map(
Path,
filter(
None,
map(
str.strip,
subprocess.check_output(
[
"git",
"ls-tree",
"-r",
"--name-only",
GIT_DEFAULT_BRANCH,
],
text=True,
).splitlines(),
),
),
)
)
COPYRIGHT_PATTERN = re.compile(
r'''
"""\n
Copyright
.*? # non-greedy match
License\.\n
"""
''',
flags=re.VERBOSE | re.IGNORECASE | re.DOTALL,
)
def replace_quoted_string_to_comments(match):
string = match.group().replace('"""', "").strip()
string = "\n".join(f"# {line}".strip() for line in string.splitlines())
string += "\n# " + "=" * 78
return string
for file in GIT_TRACKED_FILES:
try:
content = file.read_text(encoding="utf-8")
except UnicodeError:
continue # non-text file
updated_content = COPYRIGHT_PATTERN.sub(replace_quoted_string_to_comments, content)
file.write_text(updated_content, encoding="utf-8") |
Motivation
As per the title, fix module docstrings and copyright headers.
Modifications
Before:
After:
LICENSE
.Checklist