From 4f81418f890be7be3f7f53f56a0ba8d08fc2dd9a Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Nov 16 2016 19:23:21 +0000 Subject: Do a better job of ignoring pylint no-member errors Several files had pylint no-member disabled for the entire file to avoid a few specific false positives for the test. This will prevent us finding genuine bugs in those files. Instead, add a project level `.pylintrc` which lists specific member names that pylint has trouble with as generated-members. The only risk with this is if there happens to be a genuine no-member error for a different member with the same name as one of these whitelisted members, but that seems like a smaller risk than the risk of there being a genuine no-member error in any of the files where we were turning the check off for the entire file. This will also avoid the same errors in files which didn't have a file-wide no-member, including all the tests. Most of these false positives are caused by modules being clever about stuff and may not be possible for pylint to fix, but one does seem like a straight-up pylint bug, and I've reported it: https://github.com/PyCQA/pylint/issues/1165 for that one I added a single-line disable of no-members instead of including __members__ in the `generated-members` list. --- diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..0e701f7 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,22 @@ +[TYPECHECK] + +# add,bind,close,commit,delete,flush,rollback are for SQLAlchemy's +# scoped_session implementation, which uses __call__ to pass the call +# to a backing instance + +# secure_filename is from werkzeug, which lazy loads functions from +# submodules + +# get_object,set_target,shorthand,target are for some kind of +# shenanigans going on with flask and werkzeug proxying and pygit2 + +# GIT_REPOSITORY_INIT_SHARED_GROUP is for a constant we get from +# pygit2; we could use: +# pygit2.GIT_REPOSITORY_INIT_SHARED_GROUP +# instead of: +# pygit2.C.GIT_REPOSITORY_INIT_SHARED_GROUP +# and avoid the pylint error, but per +# https://github.com/libgit2/pygit2/issues/483 +# that only works since a commit in early 2015 which may be too new +# to be safe +generated-members=GIT_REPOSITORY_INIT_SHARED_GROUP,add,bind,close,commit,delete,flush,get_object,rollback,secure_filename,set_target,shorthand,target diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py index fc65844..66727d5 100644 --- a/pagure/api/__init__.py +++ b/pagure/api/__init__.py @@ -12,7 +12,6 @@ API namespace version 0. # pylint: disable=invalid-name # pylint: disable=too-few-public-methods -# pylint: disable=no-member # pylint: disable=too-many-locals import codecs @@ -424,7 +423,7 @@ def api_error_codes(): } ''' - errors = {val.name: val.value for val in APIERROR.__members__.values()} + errors = {val.name: val.value for val in APIERROR.__members__.values()} # pylint: disable=no-member return flask.jsonify(errors) diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index 514a1af..83711c8 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -10,9 +10,6 @@ Internal endpoints. """ -# pylint: disable=no-member - - import shutil import tempfile import os diff --git a/pagure/lib/git.py b/pagure/lib/git.py index bf5c87f..fff6dc1 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -12,7 +12,6 @@ # pylint: disable=too-many-arguments # pylint: disable=too-many-locals # pylint: disable=too-many-statements -# pylint: disable=no-member # pylint: disable=too-many-lines diff --git a/pagure/lib/model.py b/pagure/lib/model.py index d69f215..ab6e6fe 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -44,7 +44,6 @@ ERROR_LOG = logging.getLogger('pagure.model') # pylint: disable=invalid-name # pylint: disable=too-few-public-methods # pylint: disable=no-init -# pylint: disable=no-member # pylint: disable=too-many-lines diff --git a/pagure/ui/admin.py b/pagure/ui/admin.py index 951c67f..a420bfc 100644 --- a/pagure/ui/admin.py +++ b/pagure/ui/admin.py @@ -8,9 +8,6 @@ """ -# pylint: disable=no-member - - from functools import wraps import flask diff --git a/pagure/ui/app.py b/pagure/ui/app.py index 66ee14e..5d85c70 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -23,10 +23,6 @@ from pagure import (APP, SESSION, login_required, admin_session_timedout) -# Application -# pylint: disable=no-member - - @APP.route('/browse/projects', endpoint='browse_projects') @APP.route('/browse/projects/', endpoint='browse_projects') @APP.route('/') diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index aaccfba..6a8a8fe 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -14,7 +14,6 @@ # pylint: disable=too-many-locals # pylint: disable=too-many-statements # pylint: disable=too-many-lines -# pylint: disable=no-member import flask diff --git a/pagure/ui/groups.py b/pagure/ui/groups.py index e3110fd..2c05070 100644 --- a/pagure/ui/groups.py +++ b/pagure/ui/groups.py @@ -8,8 +8,6 @@ """ -# pylint: disable=no-member - import flask from sqlalchemy.exc import SQLAlchemyError diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index 6389545..eb73d85 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -8,7 +8,6 @@ """ -# pylint: disable=no-member # pylint: disable=too-many-lines # pylint: disable=too-many-branches # pylint: disable=too-many-locals diff --git a/pagure/ui/login.py b/pagure/ui/login.py index 5eb9dfc..cdb6757 100644 --- a/pagure/ui/login.py +++ b/pagure/ui/login.py @@ -9,9 +9,6 @@ """ -# pylint: disable=no-member - - import datetime import urlparse diff --git a/pagure/ui/plugins.py b/pagure/ui/plugins.py index 84e0117..0c8915d 100644 --- a/pagure/ui/plugins.py +++ b/pagure/ui/plugins.py @@ -9,7 +9,6 @@ """ # pylint: disable=too-many-branches -# pylint: disable=no-member import flask diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 924ca03..fe4592c 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -8,7 +8,6 @@ """ -# pylint: disable=no-member # pylint: disable=too-many-lines # pylint: disable=too-many-branches # pylint: disable=too-many-locals