-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
GH-137623: Begin enforcing docstring length in Argument Clinic #137624
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
base: main
Are you sure you want to change the base?
Conversation
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 think that we should check the length for all lines, not only the first one. And the limit should be 72 for functions, __new__
and __init__
, and 68 for other methods.
Also, should this be an error or warning?
@@ -15,7 +15,7 @@ def __post_init__(self) -> None: | |||
def report(self, *, warn_only: bool = False) -> str: | |||
msg = "Warning" if warn_only else "Error" | |||
if self.filename is not None: | |||
msg += f" in file {self.filename!r}" | |||
msg += f" in file '{self.filename}'" |
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.
Why?
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.
On Windows, !r
prints paths with \\
, which is wrong. Happy to move to a different PR?
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.
On other hand, if the filename contain special characters it will be shown in the repr format, this is why !r
is often used. This is not actual in this case, when all filenames should be good, but !r
is used multiple times for file names in the clinic code, so changing it only in this particular case is not reasonable. Open a separate issue for all cases.
f"Lines should be no longer than 72 characters.") | ||
else: | ||
if f.full_name in OVERLONG_BODY: | ||
fail(f"Remove {f.full_name!r} from OVERLONG_BODY!\n") |
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.
Should not it be a warning?
@@ -0,0 +1,433 @@ | |||
OVERLONG_SUMMARY = frozenset(( |
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.
Another possible approach is to add a decorator that will set the flood for the function. This will keep it closer to the function definition, but it will be harder to get a list of all the flagged functions.
I don't know which approach is better, I'm just showing an alternative possibility.
@@ -15,7 +15,7 @@ def __post_init__(self) -> None: | |||
def report(self, *, warn_only: bool = False) -> str: | |||
msg = "Warning" if warn_only else "Error" | |||
if self.filename is not None: | |||
msg += f" in file {self.filename!r}" | |||
msg += f" in file '{self.filename}'" |
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.
On other hand, if the filename contain special characters it will be shown in the repr format, this is why !r
is often used. This is not actual in this case, when all filenames should be good, but !r
is used multiple times for file names in the clinic code, so changing it only in this particular case is not reasonable. Open a separate issue for all cases.
Uh oh!
There was an error while loading. Please reload this page.