Pylint コンフィグファイル
eclipse で Pylint の設定をするとき、「—indent-string="○○"」(※○は半角スペース)と設定しても、Pylint 実行時にはスペースの数が2個ではなく1個になってしまう。
そこで、コンフィグファイルを作成しそれを編集して読み込ませることにした。
以下のようなパス検索が行われているようだ。
・カレントディレクトリ/pylintrc
・環境変数「PYLINTRC」で定義されているパス
・ホームディレクトリ/.pylintrc
・/etc/pylintrc
・config.py(76行目~)
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | # location of the configuration file ########################################## def find_pylintrc(): """search the pylint rc file and return its path if it find it, else None """ # is there a pylint rc file in the current directory ? if exists( 'pylintrc' ): return abspath( 'pylintrc' ) if isfile( '__init__.py' ): curdir = abspath(os.getcwd()) while isfile(join(curdir, '__init__.py' )): curdir = abspath(join(curdir, '..' )) if isfile(join(curdir, 'pylintrc' )): return join(curdir, 'pylintrc' ) if 'PYLINTRC' in os.environ and exists(os.environ[ 'PYLINTRC' ]): pylintrc = os.environ[ 'PYLINTRC' ] else : user_home = expanduser( '~' ) if user_home = = '~' or user_home = = '/root' : pylintrc = ".pylintrc" else : pylintrc = join(user_home, '.pylintrc' ) if not isfile(pylintrc): if isfile( '/etc/pylintrc' ): pylintrc = '/etc/pylintrc' else : pylintrc = None return pylintrc PYLINTRC = find_pylintrc() ENV_HELP = ''' The following environment variables are used : * PYLINTHOME path to the directory where data of persistent run will be stored. If not found, it defaults to ~/.pylint.d/ or .pylint.d (in the current working directory). * PYLINTRC path to the configuration file. If not found, it will use the first existent file in ~/.pylintrc, /etc/pylintrc. ''' % globals () |
コンフィグファイルの作成には、「pylint --generate-rcfile」を行えばよい。
たとえば、Windowsマシンで Python が Eドライブにある場合、このように作成する。
1: e:\>mkdir \etc
2:
3: e:\>pylint --generate-rcfile > \etc\pylintrc
4:
5: e:\>
0 件のコメント:
コメントを投稿