Skip to content

Conversation

@flying-sheep
Copy link
Contributor

@flying-sheep flying-sheep commented Aug 30, 2017

self.assertEqual(cmd._warnings, 0)

# check that includes work to test #31292
metadata['long_description'] = f'title\n=====\n\n.. include:: {os.devnull}'
Copy link
Member

Choose a reason for hiding this comment

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

Could you use explicit formatting, so that backporting the fix becomes easier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, will do in a second.

def _check_rst_data(self, data):
"""Returns warnings when the provided data doesn't compile."""
source_path = StringIO()
source_path = self.distribution.script_name or 'long_description'
Copy link
Member

Choose a reason for hiding this comment

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

Do you think it would be better to have a name looking like <something>, to hint that this is not a real filename?

(I forget which stdlib module uses <stdin> but I like the convetion)

Copy link
Contributor Author

@flying-sheep flying-sheep Aug 30, 2017

Choose a reason for hiding this comment

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

I like the convetion

me too! the rST data is always retrieved via self.distribution.get_long_description(), so some variant of long_description seems to be most informative to me.

maybe something like this?

source_path = '<long_description>'
if self.distribution.script_name:
    source_path = '{} {}'.format(self.distribution.script_name, source_path)

Copy link
Member

Choose a reason for hiding this comment

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

That depends if source_path has to be a path-like string, or arbitrary text.

I see your point that a warning or error message saying only «setup.py: bad include bla bla» may not be enough to let the user understand that the issue is reST in long_description, especially if the text is read from a README or other file.

If source_path is for human display only and doesn’t have to look like a file path, then +1 to your idea, maybe with parens rather than brackets: setup.py (long_description) / fallback distutils (long_description)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

at multiple points the attribute docs say something like “Path to or description of the input source being processed”, which makes me assume that free-form text is OK.


document = nodes.document(settings, reporter, source=source_path)
document.note_source(source_path, -1)
document.note_source(StringIO(), -1)
Copy link
Member

Choose a reason for hiding this comment

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

What does note_source do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it sets current_source and current_line, the former also being “Path to or description of the input source being processed”

will change

Copy link
Member

@merwok merwok Aug 30, 2017

Choose a reason for hiding this comment

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

Would it be easy to add a test for this too? @flying-sheep

Copy link
Contributor Author

@flying-sheep flying-sheep Sep 2, 2017

Choose a reason for hiding this comment

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

so distutils went against this recommendation and instantiates the class directly.

new_document does exactly the same thing except that it also creates a noisy reporter instead of a silent one, so i think we can skip a test here.

note that decode_path is just something like ensure_unicode and while new_document talks of paths, the document class says “Path to or description of the input source being processed”

Copy link
Member

Choose a reason for hiding this comment

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

Ok but I would just like to be sure about what the change does. Is the source_path used in the error message or warning text maybe? Even without a unit test, does the command-line output make sense for a human reader?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@flying-sheep flying-sheep Sep 18, 2017

Choose a reason for hiding this comment

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

sorry for the delay! i looked into it, and it needs to be a path after all if you use a relative path for a include or csv_table directive. i adjusted the test accordingly

@merwok
Copy link
Member

merwok commented Aug 30, 2017

I’m not sure that Travis or buildbots have docutils installed to test things, but I assume you tested locally.

Thanks for the patch! LGTM

@flying-sheep
Copy link
Contributor Author

flying-sheep commented Aug 30, 2017

yup, sure did.

thanks for the quick and pleasant review process!

@merwok merwok self-assigned this Sep 1, 2017
Copy link
Member

@merwok merwok left a comment

Choose a reason for hiding this comment

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

One question left

@bedevere-bot
Copy link

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 didn't expect the Spanish Inquisition!. 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.

@flying-sheep
Copy link
Contributor Author

flying-sheep commented Sep 2, 2017

Answered above. I didn't expect the Spanish Inquisition!

@bedevere-bot
Copy link

Nobody expects the Spanish Inquisition!

@merwok: please review the changes made to this pull request.



HERE = Path(__file__).parent
INCLUDE_TEST_PATH = (HERE / 'includetest.rst').relative_to(Path.cwd())
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind using os.path functions to make it easier to backport the patch?

# check that includes work to test #31292
metadata['long_description'] = 'title\n=====\n\n.. include:: {}'.format(INCLUDE_TEST_PATH)
cmd = self._run(metadata, strict=1, restructuredtext=1)
self.assertEqual(cmd._warnings, 0)
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to test the value of the long description (to see the desired text included)?

@bedevere-bot
Copy link

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 didn't expect the Spanish Inquisition!. 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.

@merwok merwok changed the base branch from 3.6 to master September 20, 2017 21:59
@merwok merwok changed the base branch from master to 3.6 September 20, 2017 22:00
@merwok
Copy link
Member

merwok commented Sep 20, 2017

I didn’t notice that the PR was for 3.6. Could you rebase the changes for master?

@ned-deily
Copy link
Member

@flying-sheep Thanks for the PR. As @merwok noted earlier, the PR needs to be based against the cpython "master" branch, not the "3.6" branch. As I don't think there is any practical way to modify the existing PR, I'm closing this one; please resubmit a new PR against master. Thanks!

https://devguide.python.org/pullrequest/

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.

5 participants