Skip to content

bpo-17972: Document findsource in inspect.rst#6992

Closed
Carreau wants to merge 1 commit into
python:masterfrom
Carreau:findsourcedoc
Closed

bpo-17972: Document findsource in inspect.rst#6992
Carreau wants to merge 1 commit into
python:masterfrom
Carreau:findsourcedoc

Conversation

@Carreau
Copy link
Copy Markdown
Contributor

@Carreau Carreau commented May 19, 2018

From the discussion in bpo-1792, it seem that findsource is mostly low
level, while getsource is higher level.

This does not completely fix bpo-17972 as many methonds need to be
marked either private, or documented

https://bugs.python.org/issue17972

From the discussion in bpo-1792, it seem that findsource is mostly low
level, while getsource is higher level.

This does not completely fix bpo-17972 as many methonds need to be
marked either private, or documented
@matrixise matrixise added the docs Documentation in the Doc dir label May 15, 2019
Copy link
Copy Markdown
Member

@JulienPalard JulienPalard left a comment

Choose a reason for hiding this comment

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

LGTM with nits.

You could maybe also state that findsource does not unwraps?

Comment thread Doc/library/inspect.rst

If *object* is a wrapper function (that is to say has a :attr:`__wrapped__`
field, :func:`getsource` will follows the chain of :attr:`__wrapped__`
attributes returning the last object in the chain using :func:`unwrap`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missing a dot at end of sentence:

Suggested change
attributes returning the last object in the chain using :func:`unwrap`
attributes returning the last object in the chain using :func:`unwrap`.

Comment thread Doc/library/inspect.rst

.. function:: findsource(object)

Return the entire source file and starting line number for an object.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd be explicit that the function is returning a tuple, maybe by starting like this and describing both elements:

Return a tuple ``(lines, lnum)`` where *lines* is ...

Comment thread Doc/library/inspect.rst
Return the entire source file and starting line number for an object.

The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a list of all the lines
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The sentence starting here may be redundent if you fix the previous comment.

Comment thread Doc/library/inspect.rst

The argument may be a module, class, method, function, traceback, frame,
or code object. The source code is returned as a list of all the lines
in the file and the line number indexes a line in that list. An OSError
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please link to the actual exception, at least as a visual hint while reading (this make it rendered differently in HTML):

Suggested change
in the file and the line number indexes a line in that list. An OSError
in the file and the line number indexes a line in that list. An :exc:`OSError`

@bedevere-bot
Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes docs Documentation in the Doc dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants