Pylint help needed



  • context: we have a medium sized project done in python, it started a few months ago and it was supposed to be small, as it turns out, it isn't anymore.

    i'm currently trying to integrate pylint into our workflow.

    i made a .pylintrc file with defaults that are more or less what we want, but i can't find a way to run it for the entire project. and pylint documentation only deals with one file at a time.

    closest thing i've got is running this from the console:
    pylint **/*.py
    with that it scans all the files in the project. but i can't get it to ignore certain files (IE alembic migrations)
    i have this line in the .pylintrc:
    ignore=test,alembic
    but it's not working.

    anyone has experience doing something like this?
    my goal currently is to have some kind of command line to put in a pre-commit hook.



  • @Jarry Have you tried bypassing pylint for it?

    find -name test -prune -o -name alembic -prune -o -exec pylint {} +


  • Winner of the 2016 Presidential Election

    @Jarry said in Pylint help needed:

    but i can't find a way to run it for the entire project. and pylint documentation only deals with one file at a time.

    Run it against a directory, for example pylint ./ or pylint src. At that point the test and alembic skips will kick in.



  • @PleegWat
    uhm, on mac that specific command doesn't work, but i'll see if i can go down that alley



  • @Jarry Doesn't have that version of -exec, I expect. Should be able to replace it with -print0 | xargs -0 pylint or -print | xargs pylint. But youu'd better try @pydsigner's suggestion first.



  • @pydsigner
    when i try to run it against the directory with pylint ./ it just evaluates the root module.
    if i do pylint ../myproject it evaluates the entire project, and honours the ignores. :confused:

    also: i'm getting lots of:
    E: 1, 0: Unable to import 'cli' (import-error)
    where cli is a module(folder) in the root of my project...


  • Winner of the 2016 Presidential Election

    @Jarry said in Pylint help needed:

    @pydsigner
    when i try to run it against the directory with pylint ./ it just evaluates the root module.
    if i do pylint ../myproject it evaluates the entire project, and honours the ignores. :confused:

    also: i'm getting lots of:
    E: 1, 0: Unable to import 'cli' (import-error)
    where cli is a module(folder) in the root of my project...

    Hmm I think they might have changed something recently, I'm getting the same stuff. Looking at the help:

    pylint [options] module_or_package
    

    I guess this wasn't affecting me when I ran pylint against a whole project on account of using pytest-pylint. That setup, or a similar one with a test framework you're already using, might help you in your situation.



  • @pydsigner
    Thankyou! that looks interesting.
    right now we're on our way to organize the project better and give it tests, linting, et al. with the final goal of getting CI finally working on it.
    currently we are are using unittest, and have too few tests.
    py.test looks better, i think i'll read on that and if it's good push for it to be included in our stack.

    if you have any link on how to organize a python project it'll help me a lot. it's my first project in python that goes beyond a few automation scripts, and i'm finding it hard to get it organized.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.