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

PEP 655: Integrate feedback from S Pradeep Kumar #2323

Merged
merged 3 commits into from
Feb 15, 2022

Conversation

davidfstr
Copy link
Contributor

No description provided.


Therefore:

::
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
::
.. code-block: python

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to Sphinx documentation, .. code-block:: python is equivalent to just :: in regular RST documents. And indeed using the former form appears to have no effect.

Strangely, neither form actually syntax-highlights Python code in color, at least in PEPs.

Copy link
Member

Choose a reason for hiding this comment

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

Coloured syntax highlighting is planned via PEP 676, you can see a preview:

So a TypeScript code block would be useful for that particular snippet.

Copy link
Member

Choose a reason for hiding this comment

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

Seconding Hugo -- the default for literal blocks is Python, but explicitness is always better, and it allows highlighting different languages, such as the TypeScript code in this PEP.

A

Copy link
Member

Choose a reason for hiding this comment

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

Seconding Hugo and Adam as well. Furthermore, as that page also mentions, that default is fully configurable on a per-project and per-file basis, and we have discussed doing so in the past.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll make a separate PR that marks the language for non-Python blocks

Presumably the PEP repo will be configured to use Python as the default syntax-highlighting language, so I won't bother to explicitly set the default language to Python in this specific PEP.

Copy link
Member

Choose a reason for hiding this comment

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

Its still a good idea to explicitly specify the language in new PEPs, as it is more clear and consistent and we've discussed using a different default (though I think our current thinking, at least between @AA-Turner and myself, is to stick with python and modify any others accordingly), but it isn't critical.

Copy link
Member

Choose a reason for hiding this comment

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

Explicit isn't always better than implicit :)

Because virtually all code is Python, and there are a lot of Python code blocks, I think we should allow the default :: for Python (and specify the language for other code blocks).

RST isn't easy. Just yesterday I read of someone ditching it for MyST: https://twitter.com/hynek/status/1493509644228173830

We should make writing documents fluent for PEP authors and not require them to stop and look up the syntax (at least I can't always remember the syntax off the top of my head) when the double colon shortcut is so easy.

(If there's a PEP with a lot of C, I think it would be fine switching the default for that PEP to C and then using ::.)

Copy link
Member

Choose a reason for hiding this comment

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

I don't think there's harm in encouraging users to be explicit, but now that it seems we've at least informally settled on an approach going forward (use python as the default and update any non-python code blocks at least on active, process, etc PEPs), I agree with the sentiment that its overstepping to require all new PEP authors to explicitly annotate every code block (its what I would do myself in my own PEPs, but I can get a bit too carried away with purity at the expense of practicality sometimes).

Using .. language at the top of the file for PEPs like PEP 7 makes sense as well (particularly on old PEPs, to allow fixing their syntax highlighting in as little as one line rather than modifying every code block, reducing noise and churn), so long as PEP authors and editors are cognizant of it.

@JelleZijlstra
Copy link
Member

Happy to merge this whenever you want me to (unless you want Guido or Pradeep to have a look first).

@davidfstr
Copy link
Contributor Author

I'd be interested in leaving this open a few days in case @pradeep90 has any comments here, or the related typing-sig post, say until Thu 2/17 AoE.

@AA-Turner
Copy link
Member

@davidfstr given Pradeep's approval are you happy for this to be merged?

A

@davidfstr
Copy link
Contributor Author

Yes, I’m happy merging this

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.

7 participants