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

pylint_fail_under failing since pylint 2.12.0 #5405

Closed
PascalRoose opened this issue Nov 26, 2021 · 7 comments
Closed

pylint_fail_under failing since pylint 2.12.0 #5405

PascalRoose opened this issue Nov 26, 2021 · 7 comments
Labels
Bug 🪲 Downstream Bug 🪲 The problem happens in a lib depending on pylint, not pylint

Comments

@PascalRoose
Copy link

Bug description

After updating Pylint to 2.12.1 (also tried 2.12.0) it seems that pylint_fail_under does not work properly anymore. After downgrading to 2.11.1 everything seemed to work as expected.

Configuration

No response

Command used

pylint-fail-under --fail_under 7.0 --rcfile=.pylintrc src

Pylint output

-----------------------------------
Your code has been rated at 8.73/10

Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\***\venv\Scripts\pylint-fail-under.exe\__main__.py", line 7, in <module>
  File "c:\users\***\venv\lib\site-packages\pylint_fail_under\__main__.py", line 42, in main
    score = results.linter.stats["global_note"]
TypeError: 'LinterStats' object is not subscriptable

Expected behavior

Would expect the program to exit with proper exit code, without raising an exception.

Pylint version

pylint-fail-under 0.3.0

pylint 2.12.0
astroid 2.9.0
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)]

OS / Environment

Windows 10 Enterprise

Additional dependencies

No response

@PascalRoose PascalRoose added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Nov 26, 2021
@Pierre-Sassoulas Pierre-Sassoulas added Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning Regression Downstream Bug 🪲 The problem happens in a lib depending on pylint, not pylint and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling Regression Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning labels Nov 26, 2021
@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Nov 26, 2021

Do not use pylint-fail-under, we have a fail-under option directly in pylint since pylint 2.5.0.

-pylint-fail-under --fail_under 7.0 --rcfile=.pylintrc src
+pylint --fail-under=7.0 --rcfile=.pylintrc src

@PascalRoose
Copy link
Author

@Pierre-Sassoulas Did not know about this. Seems like all of my CI/CD pipelines need an update. Thanks for your help!

@parvathirajan
Copy link

@Pierre-Sassoulas Sorry to bother you again, Still --fail-under is not failing for me, even the score is lesser. It should return exit code 1 but it doesn't.

run_check (){
    message="LOCATION: $repo_dir"
    echo -e "\033[1;34mInfo: $message\033[0m"
    
    message="CHECK: Checking with '$check_name'"
    echo -e "\033[1;34mInfo: $message\033[0m"
    
    pylint --fail-under=8.0 --rcfile=.pylintrc $repo_dir
    
    if [ $? -eq 1 ]; then
        message=$2
        echo -e "\033[1;31mERROR: $message\033[0m";
        exit 1
    else
        message="[PASSED] Passed $check_name checking."
        echo -e "\033[1;32mOK: $message\033[0m"
        exit 0
    fi
}

Output:

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

OK: [PASSED] Passed pylint checking.

@Pierre-Sassoulas
Copy link
Member

@parvathirajan the exit code is not necessarily 1, it's a bit encoded exit code from 0 to 32

@parvathirajan
Copy link

parvathirajan commented Feb 23, 2022

@parvathirajan the exit code is not necessarily 1, it's a bit encoded exit code from 0 to 32

Oh Sorry! I felt really dumb here, Didn't read the word it's a bit encoded. tested it, and it's working as expected.

Also, one more question if you don't mind me ☺️ Is there a way that I can get the output of the score, from pylint cmd.

Like how we can do it with Run - score = results.linter.stats.global_note?

@Pierre-Sassoulas
Copy link
Member

No problem :) The score is shown in the output by default Your code has been rated at 7.76/10 (previous run: 7.76/10, +0.00) you could also use a custom reporter. The json reporter will have score in pylint 3.0 for example see #4741 .

@parvathirajan
Copy link

Amazing Work! hats off, Thank you so much and I really appreciate your help. Will try to contribute in the future. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Downstream Bug 🪲 The problem happens in a lib depending on pylint, not pylint
Projects
None yet
Development

No branches or pull requests

3 participants