facebookincubator / Bowler

Safe code refactoring for modern Python.
https://pybowler.io/
MIT License
1.53k stars 91 forks source link

Question: Change all args to kwargs ?!? #11

Open jedie opened 5 years ago

jedie commented 5 years ago

Is it possible to change all call args to kwargs?!? Any maybe change all signatures to e.g.: (*, foo=None)

before e.g.:

class Foo:
    def __init__(self, foo, bar):
        self.foobar(foo, bar)

    def foobar(self, foo, bar):
        print(foo, bar)

Foo("one", "two")

after:

class Foo:
    def __init__(self, *, foo, bar):
        self.foobar(foo=foo, bar=bar)

    def foobar(self, *, foo, bar):
        print(foo, bar)

Foo(foo="one", bar="two")
amyreese commented 5 years ago

This would be possible to build with a custom modifier, using the IMR for function signatures/arguments in bowler.imr, but it would be nice to support this as a default modifier.

jedie commented 5 years ago

Sound's good. Hope we see this soon :grinning:

thatch commented 5 years ago

I understand how this would work at function definition, but would you require the tedious one modifier per function?