pylint

Getting pylint warning: “No config file found, using default configuration”

旧街凉风 提交于 2019-12-08 16:54:06
问题 $ pylint --reports=n main.py Output: No config file found, using default configuration 回答1: You will get the " No config file found, using default configuration " warning if you do not have a .pylintrc file in your home directory, or if you don't specify the pylint argument --rcfile=/path/to/pylintrc . To suppress the message, on *nix: $ touch ~/.pylintrc 回答2: found a pylintrc and using it, works. Posting it here in case anyone needs it. You can Modify it to suit your project. # lint Python

Force string format in pylint

烈酒焚心 提交于 2019-12-08 16:31:52
问题 Python allows to use either single or double quotes for strings. I'd like to enforce only single quotes format in my projects. Is there any specific rule in pylint or an existing pylint plugin to achieve that? 回答1: I recently wrote a pylint plugin for this: https://pypi.python.org/pypi/pylint-quotes You can get it with pip install pylint-quotes Then to use it with pylint, pylint --load-plugins pylint_quotes <module-or-package> in the .pylintrc file, you can configure which quotes to use: #

pylint import and dynamic path modification

元气小坏坏 提交于 2019-12-08 04:42:44
问题 My projects are generally structured like this: projectname/ __init__.py python/ mymodule.py other_stuff/ more_stuff/ where __init__.py contains the following code import os mypath = os.path.dirname(os.path.realpath(os.path.abspath(__file__))) __path__ = [mypath, mypath+"/python"] This "skips" the python directory when importing to allow python code in the form from projectname import mymodule rather than from projectname.python import mymodule . This appears to break pylint however, being

VS Code PyLint Error E0602 (undefined variable) with ProtoBuf compiled Python Structure

跟風遠走 提交于 2019-12-07 16:31:15
问题 I was using Visual Studio for a long time, but it was becoming too complicated to maintain. Now I tried to move to VS Code, but it throws a number of PyLint error messages that don't make sense to me (and the program still works as expected). These errors happen primarily with Python code generated from a GoogleProtoBuf structure. For example: from lbsnstructure.lbsnstructure_pb2 import lbsnPost def geoaccuracy_within_threshold(post_geoaccuracy, min_geoaccuracy): """Checks if geoaccuracy is

Pylint not working with Emacs GUI on OS X; works from command-line

最后都变了- 提交于 2019-12-07 09:42:35
问题 When run from the command-line ( emacs filename.py ) flymake and pylint work perfectly together. Errors are highlighted properly. (Although I can't tooltip hover to get error details because it's text-mode.) When run from the GUI (Carbon Emacs) Flymake returns immediately, and the first line in the file is highlighted with the error " in <module> ". The first line is shows the error even on a "Hello World" script.) I'd like to get it working properly in GUI mode so that I can navigate with

Unneeded parts when unwrapping tuple/list

有些话、适合烂在心里 提交于 2019-12-07 07:05:11
问题 Python is all about writing beautiful code. So, I was running pylint to check the "beautifulness" of my code, when I bump into something: Unused variable 'myvar1' From this part of my code: for myvar1, myvar2 in mylist: # Do stuff just using myvar2 mylist is a list of tuples, so I'm unwrapping the tuples into two variables ( myvar1 and myvar2 ). I'm defining those two variables just to unwrap the second one, because I don't need the other. So, here's my question: Is there a way to tell the

在PyCharm中使用Pylint

冷暖自知 提交于 2019-12-07 03:59:11
简介 pylint是一个用于检查python代码中的错误,尝试强制执行编码标准的工具。它还可以查找某些类型错误,可以建议如何重构特定块的建议,并可以向您提供有关代码复杂性的详细信息。 官网:www.pylint.org/ 用户手册:https://pylint.readthedocs.io/en/latest/#note-for-windows-users 安装 在windows环境下需要在cmd命令行下执行 pip install pylint pip命令在python安装目录中的Python\Python37\Scripts目录下 配置 在 PyCharm 选择 Settings> Plugins 搜索并安装Pylint 在 PyCharm 选择 Settings>Pylint 选择并配置pylint.exe 使用 在窗口最下方会出现pylint窗口,使用绿色箭头运行就可以扫描文件。 这里有一个技巧先使用Code > Reformate Code自动整理一下格式,然后再检查会少很多问题。 如果不明白提示的含义可以查看官方消息说明:http://pylint.pycqa.org/en/latest/technical_reference/features.html#basic-checker-messages 来源: oschina 链接: https://my.oschina

Adding a path to sys.path in python and pylint

ⅰ亾dé卋堺 提交于 2019-12-06 21:49:07
问题 So. I'm aware that this question seems to have been asked to death, but none of the answers seem to address what I want to do. I have a library in another directory that I want to include in a set of other projects that I run. I don't want that library added every time I run python.. So, what I had been doing was this in my python code: import sys sys.path.append("/tmp/demo/src/my-lib") import MyClass and this worked fine. But, now that I've discovered and love pylint, it complains that E: 7,

pylint doesn't point to virtualenv python

∥☆過路亽.° 提交于 2019-12-06 18:29:53
问题 I am pretty new to python and currenty I am trying to use pylint for checking code quality. I am getting a problem. My pylint doesn't point to virtualenv python interpreter. Here is the output that I get when I run pylint --version $ pylint --version pylint 0.21.1, astng 0.20.1, common 0.50.3 Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] In virtualenv I have python 2.7 installed. Will appretiate you help if someone can point me to how to solve that.

pylint import and dynamic path modification

穿精又带淫゛_ 提交于 2019-12-06 17:29:24
My projects are generally structured like this: projectname/ __init__.py python/ mymodule.py other_stuff/ more_stuff/ where __init__.py contains the following code import os mypath = os.path.dirname(os.path.realpath(os.path.abspath(__file__))) __path__ = [mypath, mypath+"/python"] This "skips" the python directory when importing to allow python code in the form from projectname import mymodule rather than from projectname.python import mymodule . This appears to break pylint however, being unable to import any modules in the project despite $PYTHONPATH being set correctly. Creating a softlink