Patchwork error: use docstrings, not bare strings, for error classes

login
register
mail settings
Submitter michaeljedgar@gmail.com
Date Aug. 30, 2014, 3:03 p.m.
Message ID <67a45fae8b0e72895ea1.1409411038@adgar-macbookpro3.roam.corp.google.com>
Download mbox | patch
Permalink /patch/5650/
State Superseded
Headers show

Comments

michaeljedgar@gmail.com - Aug. 30, 2014, 3:03 p.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1409394140 -7200
#      Sat Aug 30 12:22:20 2014 +0200
# Node ID 67a45fae8b0e72895ea11a937153bc3130ecf48f
# Parent  bdc0e04df243d3995c7266bf7d138fddd0449ba6
error: use docstrings, not bare strings, for error classes
Martin Geisler - Aug. 31, 2014, 9:12 a.m.
michaeljedgar@gmail.com writes:

> # HG changeset patch
> # User Mike Edgar <adgar@google.com>
> # Date 1409394140 -7200
> #      Sat Aug 30 12:22:20 2014 +0200
> # Node ID 67a45fae8b0e72895ea11a937153bc3130ecf48f
> # Parent  bdc0e04df243d3995c7266bf7d138fddd0449ba6
> error: use docstrings, not bare strings, for error classes

The quotes used actually make no difference:

  >>> def foo():
  ...   'a docstring'
  ...   pass
  ... 
  >>> def bar():
  ...   """another docstring"""
  ...   pass
  ... 
  >>> foo.__doc__
  'a docstring'
  >>> bar.__doc__
  'another docstring'

However, using triple-quoted strings is much more normal. I don't have
my SSH key on this machine, but if I had I would queue this :)
Augie Fackler - Aug. 31, 2014, 9:23 a.m.
On Aug 31, 2014, at 11:12 AM, Martin Geisler <martin@geisler.net> wrote:

> michaeljedgar@gmail.com writes:
> 
>> # HG changeset patch
>> # User Mike Edgar <adgar@google.com>
>> # Date 1409394140 -7200
>> #      Sat Aug 30 12:22:20 2014 +0200
>> # Node ID 67a45fae8b0e72895ea11a937153bc3130ecf48f
>> # Parent  bdc0e04df243d3995c7266bf7d138fddd0449ba6
>> error: use docstrings, not bare strings, for error classes
> 
> The quotes used actually make no difference:
> 
>>>> def foo():
>  ...   'a docstring'
>  ...   pass
>  ... 
>>>> def bar():
>  ...   """another docstring"""
>  ...   pass
>  ... 
>>>> foo.__doc__
>  'a docstring'
>>>> bar.__doc__
>  'another docstring'
> 
> However, using triple-quoted strings is much more normal. I don't have
> my SSH key on this machine, but if I had I would queue this :)

I'll queue it then. Thanks!

> 
> -- 
> Martin Geisler
> 
> https://plus.google.com/+MartinGeisler/
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r bdc0e04df243 -r 67a45fae8b0e mercurial/error.py
--- a/mercurial/error.py	Wed Aug 27 18:35:34 2014 +0200
+++ b/mercurial/error.py	Sat Aug 30 12:22:20 2014 +0200
@@ -43,13 +43,13 @@ 
         self.hint = kw.get('hint')
 
 class ConfigError(Abort):
-    'Exception raised when parsing config files'
+    """Exception raised when parsing config files"""
 
 class OutOfBandError(Exception):
-    'Exception raised when a remote repo reports failure'
+    """Exception raised when a remote repo reports failure"""
 
 class ParseError(Exception):
-    'Exception raised when parsing config files (msg[, pos])'
+    """Exception raised when parsing config files (msg[, pos])"""
 
 class RepoError(Exception):
     def __init__(self, *args, **kw):