[Python-ideas] A proliferation of (un-)Pythonically programmatic pragmas
tjreedy at udel.edu
Mon Nov 13 19:17:26 EST 2017
On 11/13/2017 4:58 PM, Paul Moore wrote:
> On 13 November 2017 at 20:43, MRAB <python-suppose that you could have suggest to them that they follow a convention
>> such as:
>> 1. There can be multiple pragmas in a comment, separated by semicolons: if
>> you don't recognise it, skip past the semicolon.
>> 2. A pragma can be prefixed with the name of the tool, e.g. "# flake8.noqa:
>> F401": if there's a prefix, but it's not yours, skip past the semicolon.
> An informational PEP defining a common convention for pragma-style
> comments could standardise things. I'd suggest starting a discussion
> (somewhere?) with the development teams for the relevant projects
> (flake8, mypy, coverage...) with the intention of developing such a
> PEP that they could all support.
This seems like a good subject for an informational PEP. It could and I
think should include an implementation of the convention as a generator
function with parameter 'tool' that yields (option, value) pairs for
Docstring directives might be considered for points to copy or not copy.
An example is # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
'.' instead of ': ' to separate the tool prefix seems better for
multiple tools, except that the latter works better for omitting the
tool prefix when there are multiple options.
For binary options, '+' and '-' prefixes are much more compact than
'=True' and '=False' suffixes. This will be more important with
multiple directives in one comment.
Terry Jan Reedy
More information about the Python-ideas