pylint

Pylint warnings on inherited nested class members

痞子三分冷 提交于 2019-12-11 03:38:37
问题 We have some particular functionality implemented as a Python class, in order to be easily extended by our developers inheriting it. Each class has a an inner Config class with a list of items. The base class has an empty Config class, and each inheriting class defines some items into it. Then pylint complains each time the item of Config subclass is used. For example, this code: class A(object): class Config(object): def __init__(self): self.item1 = 1 self.item2 = 2 def __init__(self): self.

pylint giving not-callable error for object property that is callable

泄露秘密 提交于 2019-12-11 03:15:48
问题 Not sure if I am doing something wrong or if this is a problem with pylint . In the code below I get a linting error that self.type is not callable E1102 . Although I could just ignore it and keep working, seems like this kind of thing should be easy to fix... just can't figure out how to fix it. from typing import Callable class Thing: def __init__(self, thing_type: Callable): self._type = thing_type self._value = None @property def type(self) -> Callable: return self._type @property def

Pylint warning `W0212` with properties accessing a protected member: how to avoid?

纵饮孤独 提交于 2019-12-11 01:56:13
问题 Pylint warns for suspicious access to object's protected members. It know how to not warn when the access is from the object it‑self, however does not know how to not warn when the access is from a property of the object. Ex. class C(object): def __init__(self): C.__a = 0 a = property(lambda self: self.__a) Pylint tells “ W0212 (protected-access): Access to a protected member __a of a client class” I don't want to globally disable W0212 and I am not happy with repeatedly disabling it locally 

Validation Error: Redefined outer name from outer scope

妖精的绣舞 提交于 2019-12-10 18:07:06
问题 Not sure I get this but I got a validation error from pyLint saying: Redefining name 'a' from outer scope (line 443) (redefined-outer-name) Redefining name 'b' from outer scope (line 444) (redefined-outer-name) The code is like this: a = 98 # line 443 b = 90 # line 444 def prodNr(a, b): """Definiera prodNr""" return a * b result = prodNr(a, b) ANSWER = result Could anyone please give me a clue on how to get rid of the validation error? 回答1: Call you variables something else: def prodNr(a, b):

How to prevent python pylint complaining about socket class sendall method

随声附和 提交于 2019-12-10 02:45:00
问题 I have a bit of code using a simple tcp socket setup to test something. We run pylint --errors-only on our python files, generally as a way to validate all our code. However, the simple example code given on the python socket library documentation - http://docs.python.org/library/socket.html - will output: ************* Module SocketExample E: 16: Instance of '_socketobject' has no 'recv' member E: 18: Instance of '_socketobject' has no 'sendall' member The documentation shows these members,

Pylint W0223: Method … is abstract in class … but is not overridden

試著忘記壹切 提交于 2019-12-10 02:43:02
问题 Pylint generates this error for subclasses of an abstract class, even when those subclasses are not themselves instantiated and the methods are overridden in the concrete subclasses. Why does Pylint think my abstract subclasses are intended to be concrete? How can I shut up this warning without getting out the hammer and disabling it altogether in the rc file? 回答1: For some reason pylint think the class isn't abstract (currenly detection is done by checking for method which raise

Jenkins with pylint gives build failure

北城以北 提交于 2019-12-10 02:25:09
问题 I added a build step to execute a Python script. In this script pylint is called with the lint.Run(..args) to check the code. The script works but in the end, the build fails with the only error message: Build step 'Execute Python script' marked build as failure Someone has an idea why this happens? 回答1: it seems that your pylint execution exit with a non-zero status (missing script, bad options...), maybe you exit the script with an exception raised or a sys.exit(something_else_than_zero)

Suppress warning for both pycharm and pylint

人走茶凉 提交于 2019-12-10 01:08:52
问题 I use PyCharm to write code and I also have CI server configured to run PyLint on every PR. The problem is PyCharm and PyLint use different comments for warning suppression: # noinspection PyMethodMayBeStatic # pylint: disable=no-self-use I don't like having two comments for both PyCharm and PyLint. Is there a way to configure PyLint to understand PyCharm comments or to configure PyCharm to understand PyLint comments? 回答1: Is there a way to configure PyLint to understand PyCharm comments or

Why does it say that module pygame has no init member?

人盡茶涼 提交于 2019-12-09 07:59:01
问题 Following is the code I have: import pygame pygame.init() I'm very confused because if I try to run the file, then there seems to be no issue, but pylint says the following: E1101:Module 'pygame' has no 'init' member I have searched thoroughly for a solution to this "error". In every relevant case I found, the solution was to make sure that I have not made another file or folder with the name "pygame", because in that case, I would just be importing my own file or folder. However, I have not

how do you make a For loop when you don't need index in python?

為{幸葍}努か 提交于 2019-12-08 17:51:36
问题 if i need a for loop in python for i in range(1,42): print "spam" but don't use the "i" for anything pylint complains about the unused variable. How should i handle this? I know you can do this: for dummy_index in range(1,42): print "spam" but doing this seems quite strange to me, is there a better way? I'm quite new at python so forgive me if I'm missing something obvious. 回答1: There is no "natural" way to loop n times without a counter variable in Python, and you should not resort to ugly