pylint

Pylint complains “no value for argument 'cls'”

ε祈祈猫儿з 提交于 2019-12-01 06:49:37
I have defined the following class-method to define my object from a pandas.DataFrame instead of from a list like so: class Container(object): @classmethod def from_df(cls, df): rows = [i for _, i in df.iterrows()] return cls(rows) and pylint complains at the return line with the E1120 'code-smell': No value for argument 'cls' in constructor call I can't see anything wrong with it, and it seems to work. Does anybody else maybe have an idea what could be wrong with it? Update : Ugh, user rogalski got it (I think): I confused myself by using the same variable name for a class that comes in as

Pylint complains “no value for argument 'cls'”

自古美人都是妖i 提交于 2019-12-01 04:38:24
问题 I have defined the following class-method to define my object from a pandas.DataFrame instead of from a list like so: class Container(object): @classmethod def from_df(cls, df): rows = [i for _, i in df.iterrows()] return cls(rows) and pylint complains at the return line with the E1120 'code-smell': No value for argument 'cls' in constructor call I can't see anything wrong with it, and it seems to work. Does anybody else maybe have an idea what could be wrong with it? Update : Ugh, user

Disable pylint message for a given module or directory

你离开我真会死。 提交于 2019-12-01 03:46:45
Is there a way to disable Pylint's duplicate-code message just for test files? All of the tests in our project are DAMP so the duplicated code is by design. I understand we can add # pylint: disable=duplicate-code throughout our tests, but would rather add some sort of rule that says all files under a test/ folder will have this rule disabled. Is there a way to do this? To be more specific, I'm looking for something different from a 'run it twice' solution (which is what I've already fallen back on). It can be achieved with pylint plugin and some hack. Assume we have following directory

Specify which python version pylint should evaluate for

依然范特西╮ 提交于 2019-12-01 02:24:23
I'm using Sublime Text 3 With Pylinter to run pylint on my files. However, on the same machine, I work on files for both python 2, and python 3 projects (the code is executed on one of several remote test-VMs, via SSH. I'm modifying the files by opening them over SMB. This is my home test-lab, and I'm finally sitting down to learn py3k). Can I easily override the mechanism pylint uses to determine the python version it should lint for? Ideally, there would be an inline directive, but I have not had much luck finding anything. I'm (editing) on Windows (the remote VMs are linux, but that'

How to fix: W602 deprecated form of raising exception

本秂侑毒 提交于 2019-11-30 16:57:36
If I use pylint (via sublimerlinter) I get following warning message: W602 deprecated form of raising exception This I how I use exceptions in my code: if CONDITION == True: raise ValueError, HELPING_EXPLANATION Framester Raise your exception like this: if CONDITION == True: raise ValueError(HELPING_EXPLANATION) From PEP 8 -- Style Guide for Python Code - Programming Recommendations : When raising an exception, use raise ValueError('message') instead of the older form raise ValueError, 'message' . The paren-using form is preferred because when the exception arguments are long or include string

Why does django-lint tell me the `auto_now_add` is deprecated?

不想你离开。 提交于 2019-11-30 13:52:07
Hi fellow Djangonauts: I checked my project with django-lint , and it yields: W:211,16:MyModel: timestamp: Uses superceded auto_now or auto_now_add The commit message : auto_now/auto_now_add not technically deprecated, but they still suck. Why do they say auto_now/auto_now_add "suck"? I had no problem implementing the created/last-updated pattern with these two field parameters. Is there a better approach for this pattern? Custom Field classes? And why (if this approach is better) it hasn't been integrated into Django? The correct fix is to pass a callable as the field's default that returns

Setting up Pylint with PyDev

青春壹個敷衍的年華 提交于 2019-11-30 11:55:33
问题 I have installed pylint via easy_install. I can run pylint <filename> with success. But pydev refuses to use it. I checked "use pylint" I configured correct path I updated my python interpreter in eclipse to have pylit in pythonpath I use Eclipse Galileo I have build automatically checked I tried cleaning whole project and no errors What am I doing wrong? 回答1: I'm guessing you may need to mark the folder that contains your code as a source folder . You can do this under project properties.

Specify which python version pylint should evaluate for

泪湿孤枕 提交于 2019-11-30 08:54:24
问题 I'm using Sublime Text 3 With Pylinter to run pylint on my files. However, on the same machine, I work on files for both python 2, and python 3 projects (the code is executed on one of several remote test-VMs, via SSH. I'm modifying the files by opening them over SMB. This is my home test-lab, and I'm finally sitting down to learn py3k). Can I easily override the mechanism pylint uses to determine the python version it should lint for? Ideally, there would be an inline directive, but I have

Using Pylint to display error and warnings

懵懂的女人 提交于 2019-11-30 07:26:08
So I started using Pylint but since I am using tabs instead of spaces it is giving me as warnings, also since some methods are from base class, that are also as instance of 'GalleryUi' has no 'setModel' member while it is has QAbstractTableModel as base class, so how do i set up the Pylint to not consider these things... No config file found, using default configuration ************* Module python.gallery W: 7, 0: Found indentation with tabs instead of spaces (mixed-indentation) W: 8, 0: Found indentation with tabs instead of spaces (mixed-indentation) C: 13, 0: Trailing whitespace (trailing

Best practice for setting the default value of a parameter that's supposed to be a list in Python?

老子叫甜甜 提交于 2019-11-30 03:02:33
I have a Python function that takes a list as a parameter. If I set the parameter's default value to an empty list like this: def func(items=[]): print items Pylint would tell me "Dangerous default value [] as argument". So I was wondering what is the best practice here? Use None as a default value: def func(items=None): if items is None: items = [] print items The problem with a mutable default argument is that it will be shared between all invocations of the function -- see the "important warning" in the relevant section of the Python tutorial . I just encountered this for the first time,