Skip to content
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

gh-106368: Argument clinic: improve coverage for self.valid_line() calls #107641

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Aug 4, 2023

The early return in self.state_modulename_name() is unreachable, as state_modulename_name() is only ever called from state_dsl_start, and the first thing state_dsl_start does is check whether the line is valid:

cpython/Tools/clinic/clinic.py

Lines 4655 to 4657 in 321f0f7

if not self.valid_line(line):
return

There are two other if not self.valid_line(line) branches in clinic.py which are reachable, but are uncovered:

cpython/Tools/clinic/clinic.py

Lines 5323 to 5330 in 321f0f7

def state_function_docstring(self, line: str) -> None:
assert self.function is not None
if self.group:
fail(f"Function {self.function.name!r} has a ']' without a matching '['.")
if not self.valid_line(line):
return

cpython/Tools/clinic/clinic.py

Lines 5304 to 5306 in 321f0f7

def state_parameter_docstring(self, line: str) -> None:
if not self.valid_line(line):
return

Add a test that covers both of them.

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@AlexWaygood AlexWaygood merged commit 2c25bd8 into python:main Aug 4, 2023
@AlexWaygood AlexWaygood deleted the valid-line-coverage branch August 4, 2023 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants