diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2023-03-22 08:31:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-22 08:31:58 +0100 |
commit | 7d26dcf3ee9a0c033f1529d09fe1f600b527c1cc (patch) | |
tree | 9185b9589588d9cd950d34af4536b7b0f7ecf716 /pylint/checkers/imports.py | |
parent | d6f3ae8d72e65e89560403ca2241ec604b418bdf (diff) | |
download | pylint-git-7d26dcf3ee9a0c033f1529d09fe1f600b527c1cc.tar.gz |
Fix incorrect preferred-modules matches (#8481)
Co-authored-by: d33bs <dave.bunten@cuanschutz.edu>
(cherry picked from commit d64c0cc1484b0cbea5fd3a9dfac4c0d6ddc7d1aa)
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'pylint/checkers/imports.py')
-rw-r--r-- | pylint/checkers/imports.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pylint/checkers/imports.py b/pylint/checkers/imports.py index dee12e591..1ed70d958 100644 --- a/pylint/checkers/imports.py +++ b/pylint/checkers/imports.py @@ -922,7 +922,15 @@ class ImportsChecker(DeprecatedMixin, BaseChecker): mod_compare = [f"{node.modname}.{name[0]}" for name in node.names] # find whether there are matches with the import vs preferred_modules keys - matches = [k for k in self.preferred_modules for mod in mod_compare if k in mod] + matches = [ + k + for k in self.preferred_modules + for mod in mod_compare + # exact match + if k == mod + # checks for base module matches + or k in mod.split(".")[0] + ] # if we have matches, add message if matches: |