pylint

Why doesn't Pylint like built-in functions?

社会主义新天地 提交于 2019-11-28 18:04:59
I have a line like this: filter(lambda x: x == 1, [1, 1, 2]) Pylint is showing a warning: W: 3: Used builtin function 'filter' Why is that? is a list comprehension the recommended method? Of course I can rewrite this like this: [x for x in [1, 1, 2] if x == 1] And I get no warnings, but I was wondering if there's a PEP for this? Pylint often chatters on about stuff it shouldn't. You can disable the warning in a .pylintrc file. This page http://pylint-messages.wikidot.com/messages:w0141 indicates the problem is that filter and map have been superseded by list comprehensions. A line like this in

Python: avoiding pylint warnings about too many arguments

送分小仙女□ 提交于 2019-11-28 16:39:37
问题 I want to refactor a big Python function into smaller ones. For example, consider this following code snippet: x = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 Of course, this is a trivial example. In practice, the code is more complex. My point is that it contains many local-scope variables that would have to be passed to the extracted function, which could look like: def mysum(x1, x2, x3, x4, x5, x6, x7, x8, x9): x = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 return x The problem is that

Linter pylint is not installed

自作多情 提交于 2019-11-28 15:43:42
问题 I want to run python code in Microsoft Visual Studio Code but it gives an error: "Linter pylint is not installed" I installed: The VS Code Python extension Python3 Anaconda How can I install pylint? 回答1: Open a terminal ( ctrl+~ ) Run the command pip install pylint If that doesn't work: On the off chance you've configured a non-default python path for your editor, you'll need to match that python's install location with the pip executable you're calling from the terminal. This is an issue

pylint can't find QWidget and QApplication

那年仲夏 提交于 2019-11-28 10:03:44
import sys from PyQt5.QtWidgets import (QApplication, QWidget) app = QApplication(sys.argv) window = QWidget() window.setGeometry(50, 50, 500, 300) window.setWindowTitle('Hello, world') window.show() sys.exit(app.exec_()) I just started to learn pyqt5. I wrote this hello world app, which works. But pylint gives "E0611:No name 'QWidget' in module 'PyQt5.QtWidgets'" and same for QApplication. Is it some kind of bug in pylint? pylint --version No config file found, using default configuration pylint 1.7.2, astroid 1.5.3 Python 3.5.2 (default, Aug 18 2017, 17:48:00) [GCC 5.4.0 20160609] slavugan

pylint ignore by directory

妖精的绣舞 提交于 2019-11-28 06:57:00
问题 Following is from pylint docs: --ignore=<file> Add <file or directory> to the black list. It should be a base name, not a path. You may set this option multiple times. [current: %default] Yet I'm not having luck getting the directory part work. I have directory called migrations, which has django-south migration files. As I enter --ignore=migrations it still keeps giving me the errors/warnings in files inside migrations directory. Could it be that --ignore is not working for directories? If I

PyLint message: logging-format-interpolation

心已入冬 提交于 2019-11-28 04:47:58
For the following code: logger.debug('message: {}'.format('test')) pylint produces the following warning: logging-format-interpolation (W1202): Use % formatting in logging functions and pass the % parameters as arguments Used when a logging statement has a call form of “logging.(format_string.format(format_args...))”. Such calls should use % formatting instead, but leave interpolation to the logging function by passing the parameters as arguments. I know I can turn off this warning, but I'd like to understand it. I assumed using format() is the preferred way to print out statements in Python 3

Unintentional trailing comma that creates a tuple

不羁岁月 提交于 2019-11-28 03:31:46
问题 In Python, leaving a trailing comma like this is, of course, not a SyntaxError : In [1]: x = 1 , In [2]: x Out[2]: (1,) In [3]: type(x) Out[3]: tuple But, at the same time, if the trailing comma was put accidentally , it may be difficult to catch this kind of a "problem", especially for Python newcomers. I am thinking if we can catch this kind of a "problem" early , statically, with the help of PyCharm smart code quality control features; mypy , pylint or flake8 static code analysis tools. Or

Using Pylint with Django

放肆的年华 提交于 2019-11-28 02:47:59
I would very much like to integrate pylint into the build process for my python projects, but I have run into one show-stopper: One of the error types that I find extremely useful--: E1101: *%s %r has no %r member* --constantly reports errors when using common django fields, for example: E1101:125:get_user_tags: Class 'Tag' has no 'objects' member which is caused by this code: def get_user_tags(username): """ Gets all the tags that username has used. Returns a query set. """ return Tag.objects.filter( ## This line triggers the error. tagownership__users__username__exact=username).distinct() #

List of pylint human readable message ids?

此生再无相见时 提交于 2019-11-27 22:39:20
Recent versions of pylint allow for suppressing messages with human readable message ids. For example, instead of class MyTest(unittest.TestCase): # pylint: disable=R0904 ... you can specify: class MyTest(unittest.TestCase): # pylint: disable=too-many-public-methods ... This page lists the numeric message ids. However, I'm looking for a complete list of the human readable versions of the message ids. Where can I find that list? sthenault I don't think there exists (yet) such list on the web, though pylint --list-msgs automatically produces one. I've stumbled upon your question, searching for

Pylint “unresolved import” error in visual studio code

自闭症网瘾萝莉.ら 提交于 2019-11-27 21:09:13
I am using the following setup MacOS Mojave Python 3.7.1 Visual Studio Code 1.30 Pylint 2.2.2 Django 2.1.4 I want to use linting to make my life a bit easier in visual studio code however, every import i have states "unresolved import". Even on default django imports (i.e. from django.db import models). I presume it is because it is not seeing the virtual environment python files. Everything works just fine but but it's starting to get annoying. The interpreter choices i have are all system versions of python. It does not seem to see my virtual environment python at all (it is not in the same