[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
/ cpython Public
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

bpo-31292: Fix distutils check --restructuredtext for include directives #3248

Closed
wants to merge 6 commits into from
Closed

bpo-31292: Fix distutils check --restructuredtext for include directives #3248

wants to merge 6 commits into from

Conversation

Copy link
Contributor

flying-sheep commented Aug 30, 2017

@@ -99,6 +100,11 @@ def test_check_restructuredtext(self):
cmd = self._run(metadata, strict=1, restructuredtext=1)
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

merwok Aug 30, 2017

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

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.

sure, will do in a second.

@@ -120,7 +120,7 @@ def check_restructuredtext(self):

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

merwok Aug 30, 2017

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 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

merwok Aug 30, 2017

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

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.

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.

@@ -135,7 +135,7 @@ def _check_rst_data(self, data):
error_handler=settings.error_encoding_error_handler)

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

merwok Aug 30, 2017

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

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.

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 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 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

merwok Sep 3, 2017

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

merwok Sep 14, 2017

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 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

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

merwok approved these changes Aug 30, 2017
Copy link
Contributor Author

flying-sheep commented Aug 30, 2017

yup, sure did.

thanks for the quick and pleasant review process!

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

merwok left a comment

One question left

Copy link

bedevere-bot commented Sep 1, 2017

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.

Copy link
Contributor Author

flying-sheep commented Sep 2, 2017

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

Copy link

bedevere-bot commented Sep 2, 2017

Nobody expects the Spanish Inquisition!

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

@@ -13,6 +14,10 @@
pygments = None


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

merwok Sep 20, 2017

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

merwok Sep 20, 2017

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)?

Copy link

bedevere-bot commented Sep 20, 2017

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 changed the base branch from 3.6 to master Sep 20, 2017
merwok changed the base branch from master to 3.6 Sep 20, 2017
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?

Copy link
Member

ned-deily commented Jun 7, 2018

@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.

None yet

5 participants