Skip to content

gh-131178: Update help message for timeit CLI #131326

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

Merged
merged 3 commits into from
Mar 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Lib/test/test_timeit.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,7 @@ def test_main_negative_reps(self):
@unittest.skipIf(sys.flags.optimize >= 2, "need __doc__")
def test_main_help(self):
s = self.run_main(switches=['-h'])
# Note: It's not clear that the trailing space was intended as part of
# the help text, but since it's there, check for it.
self.assertEqual(s, timeit.__doc__ + ' ')
self.assertEqual(s, timeit.__doc__)

def test_main_verbose(self):
s = self.run_main(switches=['-v'])
Expand Down
3 changes: 1 addition & 2 deletions Lib/timeit.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
timeit(string, string) -> float
repeat(string, string) -> list
default_timer() -> float

"""

import gc
Expand Down Expand Up @@ -302,7 +301,7 @@ def main(args=None, *, _wrap_timer=None):
precision += 1
verbose += 1
if o in ("-h", "--help"):
print(__doc__, end=' ')
print(__doc__, end="")
return 0
setup = "\n".join(setup) or "pass"

Expand Down
Loading