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-128481: Add missing documentation for traceback.FrameSummary.end_{col,line} #128484

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Damien-Chen
Copy link
Contributor

@Damien-Chen Damien-Chen commented Jan 4, 2025

Doc/library/traceback.rst Show resolved Hide resolved
@@ -503,7 +503,7 @@ the module-level functions described above.
A :class:`!FrameSummary` object represents a single :ref:`frame <frame-objects>`
in a :ref:`traceback <traceback-objects>`.

.. class:: FrameSummary(filename, lineno, name, lookup_line=True, locals=None, line=None)
.. class:: FrameSummary(filename, lineno, end_lineno=None, name, lookup_line=True, locals=None, line=None, end_colno=None)
Copy link
Member

Choose a reason for hiding this comment

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

There's also an undocumented colno parameter that goes before end_colno. You can go ahead and document it too with this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood, I made the order of arguments of documentation consistent with the order of code, and it would like this
` .. attribute:: FrameSummary.end_lineno

  The last line number of the source code for this frame.

.. attribute:: FrameSummary.colno

  The column number of the source code for this frame.

.. attribute:: FrameSummary.end_colno

  The last column number of the source code for this frame.`

Copy link
Member

Choose a reason for hiding this comment

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

.. class:: FrameSummary(filename, lineno, end_lineno=None, name, lookup_line=True, locals=None, line=None, end_colno=None)

This is an illegal prototype. end_lineno cannot have a default None while name has no default. In addition, lookup_line are keyword-only:

    def __init__(self, filename, lineno, name, *, lookup_line=True,
            locals=None, line=None,
            end_lineno=None, colno=None, end_colno=None):

Let's just copy the __init__ signature for the docs.

@ZeroIntensity ZeroIntensity added needs backport to 3.13 bugs and security fixes needs backport to 3.12 bug and security fixes labels Jan 4, 2025
picnixz
picnixz previously requested changes Jan 4, 2025
@@ -503,7 +503,7 @@ the module-level functions described above.
A :class:`!FrameSummary` object represents a single :ref:`frame <frame-objects>`
in a :ref:`traceback <traceback-objects>`.

.. class:: FrameSummary(filename, lineno, name, lookup_line=True, locals=None, line=None)
.. class:: FrameSummary(filename, lineno, end_lineno=None, name, lookup_line=True, locals=None, line=None, end_colno=None)
Copy link
Member

Choose a reason for hiding this comment

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

.. class:: FrameSummary(filename, lineno, end_lineno=None, name, lookup_line=True, locals=None, line=None, end_colno=None)

This is an illegal prototype. end_lineno cannot have a default None while name has no default. In addition, lookup_line are keyword-only:

    def __init__(self, filename, lineno, name, *, lookup_line=True,
            locals=None, line=None,
            end_lineno=None, colno=None, end_colno=None):

Let's just copy the __init__ signature for the docs.

@Damien-Chen
Copy link
Contributor Author

end_lineno cannot have a default None as well ?

There is no description for the colno, end_lineno and endcolno in the __init__ function, should I add the documentation for all the above argument ?

`
.. attribute:: FrameSummary.end_lineno

  The last line number of the source code for this frame.

.. attribute:: FrameSummary.colno

  The column number of the source code for this frame.

.. attribute:: FrameSummary.end_colno

  The last column number of the source code for this frame.

`

@picnixz
Copy link
Member

picnixz commented Jan 4, 2025

end_lineno cannot have a default None as well ?

No, I meant it cannot have a default value without name having one. The problem was where it was put in the signature.

@Damien-Chen
Copy link
Contributor Author

Understood, I have fixed it with latest commit.

@Damien-Chen Damien-Chen requested a review from picnixz January 4, 2025 15:43
@@ -503,7 +503,7 @@ the module-level functions described above.
A :class:`!FrameSummary` object represents a single :ref:`frame <frame-objects>`
in a :ref:`traceback <traceback-objects>`.

.. class:: FrameSummary(filename, lineno, name, lookup_line=True, locals=None, line=None)
.. class:: FrameSummary(filename, lineno, name, lookup_line=True, locals=None, line=None, end_lineno=None, colno=None, end_colno=None)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.. class:: FrameSummary(filename, lineno, name, lookup_line=True, locals=None, line=None, end_lineno=None, colno=None, end_colno=None)
.. class:: FrameSummary(filename, lineno, name, *,\
lookup_line=True, locals=None,\
line=None, end_lineno=None, colno=None, end_colno=None)

Actually, the current (docs) signature as the code expect lookup_line and remaining parameters to be keyword only so let's also fix that here.

@@ -539,6 +539,18 @@ in a :ref:`traceback <traceback-objects>`.
trailing whitespace stripped.
If the source is not available, it is ``None``.

.. attribute:: FrameSummary.end_lineno
Copy link
Member

Choose a reason for hiding this comment

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

Those new attributes can be None I think (just check the source code first). If so, this should be specified. Also, it'd be good to say whether it's a 0-indexed or 1-indexed base (I always forget)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the code description, those new attributes can be None that is right.
And those number attributes are 1-indexed base I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants