PyCQA / modernize

Modernizes Python code for eventual Python 3 migration. Built on top of fissix (a fork of lib2to3)
https://modernize.readthedocs.org/
Other
353 stars 51 forks source link

Use @six.add_metaclass() decorator instead of six.with_metaclass()? #153

Open hroncok opened 7 years ago

hroncok commented 7 years ago

Currently the fix_metaclass fixer uses six.with_metaclass:

class Foo(Bar):
    __metaclass__ = Meta

becomes:

import six
class Foo(six.with_metaclass(Meta, Bar)):
    pass

I believe the @six.add_metaclass() decorator is more readable and the fixer might change it to this instead:

import six
@six.add_metaclass(Meta)
class Foo(Bar):
    pass

However this may have unwanted side effects (read more about them in the pull request introducing the decorator). What do you think?

(I'm willing to work on this and send a PR, but I want to have a consensus here first not to write code that will end up discarded.)