Suggestion to check for unmerged imports using Pylint

Viewed 67

Having used eslint for a few years now, one of my favorite features is no-duplicate-imports which verifies a single import statement is being used for each module.

Using a single import statement per module will make the code clearer because you can see everything being imported from that module in one line.

For example:

import { merge } from 'module';
import something from 'another-module';
import { find } from 'module';

Should be changed to

import { merge, find } from 'module';
import something from 'another-module';

I have searched around but cannot find such checker in Pylint. There are checkers for import order and duplicate imports as long as it is an exact match but nothing like the example above.

Another example that should be detected:

 from constants import CONSTANT_ONE
 from constants import CONSTANT_TWO

Pylint suggestion should be:

 from constants import CONSTANT_ONE, CONSTANT_TWO

How do you think we can achieve it with Pylint?

0 Answers
Related