Skip to content

gh-125897: Use positional-only parameter indicators for range() #125945

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 1 commit into from
Aug 11, 2025

Conversation

kbaikov
Copy link
Contributor

@kbaikov kbaikov commented Oct 24, 2024

Addresses the #125897 documentation discrepancy that the range function accepts step as a kwarg


📚 Documentation preview 📚: https://cpython-previews--125945.org.readthedocs.build/

@ghost
Copy link

ghost commented Oct 24, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news awaiting review labels Oct 24, 2024
@mpage mpage changed the title gn-125897: FIx the range function refering to step as a kwarg gh-125897: FIx the range function refering to step as a kwarg Oct 24, 2024
@mpage mpage changed the title gh-125897: FIx the range function refering to step as a kwarg gh-125897: Fix the range function refering to step as a kwarg Oct 24, 2024
Addresses the python#125897 documentation discrepancy that the range function accepts step as a kwarg
@skirpichev
Copy link
Contributor

@kbaikov, please avoid force-pushes: https://devguide.python.org/getting-started/pull-request-lifecycle

@kbaikov
Copy link
Contributor Author

kbaikov commented Dec 9, 2024

A friendly ping. Is there any decision on this issue/PR? How do i proceed?

@skirpichev
Copy link
Contributor

CC @nedbat

Perhaps, https://devguide.python.org/documentation/style-guide/#function-signatures requires a clarification. Is this for new code? How we should handle current sphinx docs, that use funny square bracket syntax?

@merwok merwok changed the title gh-125897: Fix the range function refering to step as a kwarg gh-125897: Fix range function doc referring to step as a kwarg Feb 24, 2025
Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

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

In #137610, Serhiy proposes to put /s everywhere they belong, and I strongly support this. HIs PR #137609 includes the 2 additions here, so he also approves them. I think that this should be merged first so that OP gets the proper credit.

.. class:: range(stop)
range(start, stop, step=1)
.. class:: range(stop, /)
range(start, stop, step=1, /)
Copy link
Member

Choose a reason for hiding this comment

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

I think enumerating all three cases is slightly nicer. The step argument is for advanced use-cases. Thoguhts @terryjreedy?

Suggested change
range(start, stop, step=1, /)
range(start, stop, /)
range(start, stop, step, /)

Copy link
Member

Choose a reason for hiding this comment

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

I generally prefer fewer lines, partly from experience with IDLE call tips (which would be similar in other IDEs). Serhiy generally went with fewer in his PR, as he did here, except where really needed. Two are really needed here, since the true Python-implementaton signature (start_or_stop, stop_if_needed=None, step=1, /) is definitely too baroque for the doc.

Given your approval, I will merge this and backport (as Serhiy plans to backport his changes).

@terryjreedy terryjreedy added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Aug 11, 2025
@AA-Turner AA-Turner changed the title gh-125897: Fix range function doc referring to step as a kwarg gh-125897: Use positional-only parameter indicators for range() Aug 11, 2025
@AA-Turner AA-Turner changed the title gh-125897: Use positional-only parameter indicators for range() gh-125897: Use positional-only parameter indicators for range() Aug 11, 2025
@terryjreedy terryjreedy merged commit 0c83daa into python:main Aug 11, 2025
34 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Aug 11, 2025
@miss-islington-app
Copy link

Thanks @kbaikov for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 11, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 11, 2025
@bedevere-app
Copy link

bedevere-app bot commented Aug 11, 2025

GH-137652 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Aug 11, 2025
@bedevere-app
Copy link

bedevere-app bot commented Aug 11, 2025

GH-137653 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Aug 11, 2025
AA-Turner pushed a commit that referenced this pull request Aug 11, 2025
maurycy added a commit to maurycy/cpython that referenced this pull request Aug 12, 2025
* main:
  pythongh-137288: Update 3.14 magic numbers (pythonGH-137665)
  pythongh-135228: When @DataClass(slots=True) replaces a dataclass, make the original class collectible (take 2) (pythonGH-137047)
  pythongh-126008: Improve docstrings for Tkinter cget and configure methods (pythonGH-133303)
  pythongh-131885: Use positional-only markers for ``max()`` and ``min()`` (python#131868)
  pythonGH-137426: Remove code deprecation of `importlib.abc.ResourceLoader` (pythonGH-137567)
  pythongh-125897: Mark range function parameters as positional only (python#125945)
  pythongh-137400: Fix a crash when disabling profiling across all threads (pythongh-137471)
  pythongh-115766: Fix IPv4Interface.is_unspecified (pythonGH-137326)
  pythongh-128813: cleanup C-API docs for PyComplexObject (pythonGH-137579)
  pythongh-135953: Profile a module or script with sampling profiler (python#136777)
  Fix documentation of hash in PyHash_FuncDef (python#137595)
@kbaikov kbaikov deleted the fix-issue-125897 branch August 12, 2025 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

8 participants