Skip to content

Commit

Permalink
Separate super and sub classes' snippets
Browse files Browse the repository at this point in the history
The way the snippet was set (one only snippet for both
super and sub classes) prompted the creation of super classes
of the kind:

class ClassName(object):
      '''Doc'''
      def __init__(self):
      	  super().__init__()
	  ...

calling the method super() in a subclass of 'object'
rises the 'useless-super-delegation' warning from
pylintrc.
This can be avoided by creating a separated snippet
for subclasses, in which the method super() has an
usefull effect.

Signed-off-by: Gustavo Gurgel <gukgurgel@gmail.com>
  • Loading branch information
gustavogurgel committed Jan 1, 2021
1 parent d9a5e07 commit 7a62e9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
11 changes: 5 additions & 6 deletions snippets/python-mode/class
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- mode: snippet -*-
# name: class(parent): ...
# name: class: ...
# key: class
# group: Definitions
# --
class ${1:ClassName}(${2:object}):
"""${3:Documentation for $1}
class ${1:ClassName}:
"""${2:Documentation for $1}

"""
def __init__(self${4:, args}):
super().__init__($5)
${4:$(elpy-snippet-init-assignments yas-text)}
def __init__(self${3:, args}):
${3:$(elpy-snippet-init-assignments yas-text)}
$0
13 changes: 13 additions & 0 deletions snippets/python-mode/sclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- mode: snippet -*-
# name: sclass(parent): ...
# key: sclass
# group: Definitions
# --
class ${1:SubClassName}(${2:ParentClass}):
"""${3:Documentation for $1}

"""
def __init__(self${4:, args}):
super().__init__($5)
${4:$(elpy-snippet-init-assignments yas-text)}
$0

0 comments on commit 7a62e9a

Please sign in to comment.