Fixit icon indicating copy to clipboard operation
Fixit copied to clipboard

Update imports with autofix

Open ljodal opened this issue 5 years ago • 0 comments

Hi, I'm looking into creating a rule telling users not to use a certain base class, but rather use a different one. Providing an autofix for this would require changing an import, which I can't figure out how to do. Is this currently possible?

For example I'd like to replace this:

from a import A

class MyClass(A):
    pass

with this:

from b import B

class MyClass(B):
    pass

I see that the NoNamedTupleRule leaves old imports in place and does not add an import for dataclasses, so I'm half assuming this isn't possible at the moment. Any plans to add support for this? Let me know if there's anything I can do to help :)

ljodal avatar Jan 15 '21 13:01 ljodal