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

Update Class Snippets #1873

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Update Class Snippets #1873

wants to merge 3 commits into from

Conversation

gukgurgel
Copy link

PR Summary

Address some problems of the snippet for creating classes, and they are:

  • Unnecessary call of super() method inside init() of super classes;
  • Call of super() method in Python2 syntax, which was updated in Python3

PR checklist

Please make sure that the following things have been addressed (and check the relevant checkboxes):

  • [x ] Commits respect our guidelines
  • [x ] Tests are passing properly (see here on how to run Elpy's tests)

For new features only:

  • Tests has been added to cover the change
  • The documentation has been updated

A reference to the new/recommended syntax can be found in
https://docs.python.org/3/library/functions.html#super

Signed-off-by: Gustavo Gurgel <gukgurgel@gmail.com>
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>
Signed-off-by: Gustavo Gurgel <gukgurgel@gmail.com>
@coveralls
Copy link

Coverage Status

Coverage decreased (-7.4%) to 86.863% when pulling 9c9b37a on gukgurgel:master into 4032c72 on jorgenschaefer:master.

@gopar
Copy link
Collaborator

gopar commented Feb 27, 2021

Oh nice, I like the new snippet! I will say that even though py 2 has reached EOL, there are still plenty of ppl who will continue to use for a few years (At my previous company, there is no way we'll get off py2 until years later). Because of this, I'm towards leaving the class snippet alone and only include the sclass.

@galaunay
Copy link
Collaborator

I like the idea of having class and sclass snippets.
In my opinion, we should use python3 syntax by default, and maybe providing a py2class (or else) snippet for python 2 users ?
what do you think ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants