[Python-ideas] A proliferation of (un-)Pythonically programmatic pragmas
Brice Parent
contact at brice.xyz
Wed Nov 15 04:00:52 EST 2017
I think, if it belongs to a python file, it has to follow the same rules
as the rest of the file:
- if we follow the pep8, less-than-80 chars remains the rule, whether we
are in a comment or not
- if the first of 3 following codes works, all three should (the 3
comments refer to the line of code):
some_function(foo, bar) # coverage: ignore=when>py2.7, alias=pathlib2.Path
# coverage: ignore=when>py2.7, alias=pathlib2.Path
some_function(foo, bar)
# coverage: ignore=when>py2.7
# alias=pathlib2.Path
some_function(foo, bar)
Also, having these pragmas instructions should not prevent classic
commenting in any ways, or make them harder to write or understand, so
those should all be valid:
# doing something important here
some_function(foo, bar) # coverage: ignore=when>py2.7, alias=pathlib2.Path
# coverage: ignore=when>py2.7, alias=pathlib2.Path
some_function(foo, bar)# doing something important here
# coverage: ignore=when>py2.7
# alias=pathlib2.Path
# doing something important here
some_function(foo, bar)
or (what's better for readability?)
# doing something important here
# coverage: ignore=when>py2.7
# alias=pathlib2.Path
some_function(foo, bar)
Also, why not adopt the same syntax that is already quite commonly used
for todos in many languages, with "@"?
# @todo: write tests for this function! @coverage: ignore=when>py2.7
@alias=pathlib2.Path
some_function(foo, bar)
-Brice
Le 15/11/17 à 02:12, Chris Barker a écrit :
> On Mon, Nov 13, 2017 at 5:37 PM, Barry Warsaw <barry at python.org
> <mailto:barry at python.org>> wrote:
>
> One of the things that bother me about end-line comments is that
> this is
> going to blow up line length limits.
>
>
> Is that a problem? the linters can ignore lines to long if they are
> only too long due to one of these :-)
>
> I think this could work if such
> pragma comments could apply to the following line, and multiline
> pragmas
> would be acceptable. Then you could have something like:
>
> # flake8: disable=unused-import
> # mypy: alias=pathlib2.Path
> # coverage: ignore=when>py2.7
>
>
> I'd much rather have the tools all look at the entire comment for
> their particular pragma.
>
> and then, even if you wanted to put it on the previous line, you
> would't have the line-length issue:
>
> # flake8: disable=unused-import mypy: alias=pathlib2.Path coverage:
> ignore=when>py2.7
>
> -CHB
>
> --
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R (206) 526-6959 voice
> 7600 Sand Point Way NE (206) 526-6329 fax
> Seattle, WA 98115 (206) 526-6317 main reception
>
> Chris.Barker at noaa.gov <mailto:Chris.Barker at noaa.gov>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171115/75df06fa/attachment.html>
More information about the Python-ideas
mailing list