Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore-imports option ignored #6350

Closed
jacobtylerwalls opened this issue Apr 15, 2022 · 2 comments · Fixed by #6358
Closed

ignore-imports option ignored #6350

jacobtylerwalls opened this issue Apr 15, 2022 · 2 comments · Fixed by #6358
Assignees
Labels
Bug 🪲 Configuration Related to configuration duplicate-code Related to code duplication checker Unreleased
Milestone

Comments

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Apr 15, 2022

Bug description

The ignore-imports=yes option is ignored in 2.14.

Place two files that both read like this (ideally in their own dir so you can just run that dir):

import os
import sys
import argparse
import random
import math

Configuration

I reproduced in an environment without a `pylintrc`.

Command used

pylint package_name --enable=duplicate-code --ignore-imports=y

Pylint output

************* Module c
sim/c.py:1:0: W0611: Unused import os (unused-import)
sim/c.py:2:0: W0611: Unused import sys (unused-import)
sim/c.py:3:0: W0611: Unused import argparse (unused-import)
sim/c.py:4:0: W0611: Unused import random (unused-import)
sim/c.py:5:0: W0611: Unused import math (unused-import)
************* Module b
sim/b.py:1:0: W0611: Unused import os (unused-import)
sim/b.py:2:0: W0611: Unused import sys (unused-import)
sim/b.py:3:0: W0611: Unused import argparse (unused-import)
sim/b.py:4:0: W0611: Unused import random (unused-import)
sim/b.py:5:0: W0611: Unused import math (unused-import)
sim/b.py:1:0: R0801: Similar lines in 2 files
==b:[0:5]
==c:[0:5]
import os
import sys
import argparse
import random
import math (duplicate-code)

Expected behavior

Proper output in 2.12:

************* Module c
sim/c.py:1:0: W0611: Unused import os (unused-import)
sim/c.py:2:0: W0611: Unused import sys (unused-import)
sim/c.py:3:0: W0611: Unused import argparse (unused-import)
sim/c.py:4:0: W0611: Unused import random (unused-import)
sim/c.py:5:0: W0611: Unused import math (unused-import)
************* Module b
sim/b.py:1:0: W0611: Unused import os (unused-import)
sim/b.py:2:0: W0611: Unused import sys (unused-import)
sim/b.py:3:0: W0611: Unused import argparse (unused-import)
sim/b.py:4:0: W0611: Unused import random (unused-import)
sim/b.py:5:0: W0611: Unused import math (unused-import)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Pylint version

Caused in 03cfbf3

OS / Environment

No response

Additional dependencies

No response

@jacobtylerwalls jacobtylerwalls added Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling Unreleased and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 15, 2022
@jacobtylerwalls jacobtylerwalls added this to the 2.14.0 milestone Apr 15, 2022
@jacobtylerwalls jacobtylerwalls added Bug 🪲 Configuration Related to configuration duplicate-code Related to code duplication checker labels Apr 15, 2022
@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Apr 15, 2022

I think we put some option in the global configuration namespace but the name is now misleading and should be something like "ignore-import-for-similarity" Edit: It's not has bad as I thought we're still talking about the similarity checker here..

@DanielNoord
Copy link
Collaborator

I think I know what is causing this. set_option of Similar sets the options from .config to an attribute of the checker. This allows running Similar standalone as it no longer requires a linter.config object.
With optparse set_option got called all the time (which is one of the things we wanted to avoid in argparse).

However, I think we might be calling it a little too little now. I'll assign myself, although I'm not sure if I can fix this before the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Configuration Related to configuration duplicate-code Related to code duplication checker Unreleased
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants