pylint

Pylint disable all warnings for a file

回眸只為那壹抹淺笑 提交于 2019-11-27 11:37:18
问题 We are using pylint within our build system. We have a python package within our code base that has throwaway code, and I'd like to disable all warnings for a module temporarily so I can stop bugging the other devs with these superfluous messages. Is there an easy way to pylint: disable all warnings for a module? 回答1: From the PyLint FAQ With Pylint < 0.25, add # pylint: disable-all at the beginning of the module. Pylint 0.26.1 and up have renamed that directive to # pylint: skip-file (but

Why doesn't Pylint like built-in functions?

我只是一个虾纸丫 提交于 2019-11-27 11:02:00
问题 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? 回答1: 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

How do I get PyLint to recognize numpy members?

落爺英雄遲暮 提交于 2019-11-27 10:28:34
I am running PyLint on a Python project. PyLint makes many complaints about being unable to find numpy members. How can I avoid this while avoiding skipping membership checks. From the code: import numpy as np print np.zeros([1, 4]) Which, when ran, I get the expected: [[ 0. 0. 0. 0.]] However, pylint gives me this error: E: 3, 6: Module 'numpy' has no 'zeros' member (no-member) For versions, I am using pylint 1.0.0 (astroid 1.0.1, common 0.60.0) and trying to work with numpy 1.8.0 . If using Visual Studio Code with Don Jayamanne's excellent Python extension , add a user setting to whitelist

How can I use Emacs Flymake mode for python with pyflakes and pylint checking code?

落爺英雄遲暮 提交于 2019-11-27 09:34:09
问题 For checking code in python mode I use flymake with pyflakes Also I want check code style (pep8) with pylint (description on the same page with pyflakes) This solutions work. But I can't configure flymake for work with pyflakes and pylint together. How can I do it? 回答1: Well, flymake is just looking for a executable command thats output lines in a predefined format. You can make a shell script for example that will call successively all the checkers you want... You must also make sure that

PyLint, PyChecker or PyFlakes? [closed]

烂漫一生 提交于 2019-11-27 05:43:28
I would like to get some feedback on these tools on : features; adaptability; ease of use and learning curve. e-satis Well, I am a bit curious, so I just tested the 3 myself right after asking the question ;-) Ok, this is not a very serious review but here is what I can say : I tried the tools with the default settings (it's important because you can pretty much choose your check rules) on the following script : #!/usr/local/bin/python # by Daniel Rosengren modified by e-satis import sys, time stdout = sys.stdout BAILOUT = 16 MAX_ITERATIONS = 1000 class Iterator(object) : def __init__(self):

invoking pylint programmatically

自作多情 提交于 2019-11-27 04:18:50
问题 I'd like to invoke the pylint checker, limited to the Error signalling part, as part of my unit testing. so I checked the pylint executable script, got to the pylint.lint.Run helper class and there I got lost in a quite long __init__ function, ending with a call to sys.exit() . anybody ever tried and managed to do so? the dream-plan would be this: if __name__ == '__main__': import pylint.lint pylint.lint.something(__file__, justerrors=True) # now continue with unit testing any hints? other

pylint 1.4 reports E1101(no-member) on all C extensions

时光怂恿深爱的人放手 提交于 2019-11-27 04:10:17
We've been long-time fans of pylint . Its static analysis has become a critical part of all our python projects and has saved tons of time chasing obscure bugs. But after upgrading from 1.3 -> 1.4, almost all compiled c extensions result in E1101(no-member) errors. Projects that previously run perfectly clean through pylint 1.3 now complain about almost every C extension member with E1101. We've been forced to disable E1101 errors, but this materially detracts from the usefulness of pylint . For example, this perfectly valid use of the lxml package r"""valid.py: demonstrate pylint 1.4 error"""

Instance attribute attribute_name defined outside __init__

回眸只為那壹抹淺笑 提交于 2019-11-27 03:14:22
I split up my class constructor by letting it call multiple functions, like this: class Wizard: def __init__(self, argv): self.parse_arguments(argv) self.wave_wand() # declaration omitted def parse_arguments(self, argv): if self.has_correct_argument_count(argv): self.name = argv[0] self.magic_ability = argv[1] else: raise InvalidArgumentsException() # declaration omitted # ... irrelevant functions omitted While my interpreter happily runs my code, Pylint has a complaint: Instance attribute attribute_name defined outside __init__ A cursory Google search is currently fruitless. Keeping all

PyLint message: logging-format-interpolation

偶尔善良 提交于 2019-11-27 00:18:52
问题 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

PyLint not recognizing cv2 members

这一生的挚爱 提交于 2019-11-26 16:27:12
问题 I am running pylint on an opencv project and I am getting many pylint errors in VS code about members not being present. Example code: import cv2 cv2.imshow(....) Errors obtained: However , the code runs correctly without any errors. Versions : pylint 1.8.1 , astroid 1.6.0 回答1: This is from pylint. You can generate a pylint config file in the root of your project with this command: (I find this to be helpful if you work in a team or on different computers from the same repo) pylint --generate