Black: Black should remove empty parentheses after class names

Created on 19 Apr 2018  ·  12Comments  ·  Source: psf/black

class SomeClass():
    ...

should be just

class SomeClass:
    ....

Those are equivalent both on Python 3 and Python 2.

enhancement good first issue help wanted

All 12 comments

@ambv can I take this one?

Go for it!

@skapil Let me know if anything is unclear in the codebase. Happy to guide you through it!

Thanks @ambv. I am still getting trying to understand the code and looks like code making sense for me slowly. However, I would definitely reach out if I would have any question!!

@ambv : Should we remove the braces or would it be better to replace it with

class SomeClass():
    ...

# to

class SomeClass(object):
    ...

Wouldn't inheriting object be more pythonic? How costly would it be in terms of perf?

I like the latter under the rule _it is better to be explicit than implicit_.

In python2 those things are not equivalent

On Tue, Apr 24, 2018, 14:26 cclauss notifications@github.com wrote:

I like the latter under the rule it is better to be explicit than
implicit
_.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/ambv/black/issues/145#issuecomment-383929661, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEtBK5-TQK64HVI5ZeofHgkHVdXJaGks5trygfgaJpZM4TbNFO
.

Agreed but at this stage (Python 2.7) what are the downsides of autoswitching to New Style Classes. I know that on earlier versions of Python it might have been a problem to autoswitch but in current Python 2, are there still problems in moving to New Style Class?

(object) on Python 3 is just noise. Don't use it. Explicit is better than implicit if it communicates something extra. In Python 3 it doesn't.

As Zsolt pointed out, in Python 2 adding this changes meaning. Black is not in the business of breaking user code.

Fair enough! Just wanted to start a discussion to ensure it is thought about as I didn't see that possibility being discussed.

@ambv Can you please review https://github.com/ambv/black/pull/180. Working on tests right now.

This is fixed by #180. Thanks, @skapil! ✨ 🍰 ✨

Was this page helpful?
0 / 5 - 0 ratings