pylint

What does pylint's “Too few public methods” message mean

旧街凉风 提交于 2019-11-27 20:20:58
问题 I'm running pylint on some code, and receiving the error "Too few public methods (0/2)". What does this message mean? The pylint docs are not helpful: Used when class has too few public methods, so be sure it's really worth it. 回答1: The error basically says that classes aren't meant to just store data, as you're basically treating the class as a dictionary. Classes should have at least a few methods to operate on the data that they hold. If your class looks like this: class MyClass(object):

invoking pylint programmatically

时光总嘲笑我的痴心妄想 提交于 2019-11-27 18:44:52
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 than "copy the __init__ method and skip the sys.exit() ", I mean? I don't need the tests to be run by

Is it possible to ignore one single specific line with pylint?

荒凉一梦 提交于 2019-11-27 18:38:39
I have the following line in my header: import config.logging_settings This actually changes my python logging settings, but pylint thinks it is an unused import. I do not want to remove unused-import warnings in general so is it possible to just ignore this one specific line? I wouldn't mind having a .pylintrc for this project so answers changing a config file will be accepted. Otherwise, something like this will also be appreciated: import config.logging_settings # pylint: disable-this-line-in-some-way Pylint message control is documented in the Pylint manual : Is it possible to locally

For Pylint, is it possible to have a different pylintrc file for each Eclipse project?

十年热恋 提交于 2019-11-27 15:59:49
问题 I saw I can change it per Eclipse instance using this solution. I would like to set it per project. Is it possible? 回答1: This is not Eclipse specific, but it may help anyway. According to pylint command line options: You can specify a configuration file on the command line using the --rcfile option. Otherwise, Pylint searches for a configuration file in the following order and uses the first one it finds: pylintrc in the current working directory .pylintrc in the current working directory If

How do I get Pylint message IDs to show up after pylint-1.0.0?

本小妞迷上赌 提交于 2019-11-27 14:29:59
问题 Starting with pylint-1.0.0 the --include-ids argument is no longer allowed. How do I get: ************* Module foo.bar E:199,11: Module 'yaml' has no 'scanner' member (no-member) ************* Module foo.baz W:153,27: Unused variable '_filenames' (unused-variable) to show the IDs (e.g. W0142), for each warning? 回答1: The new way to specify this is the command line parameter '--msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}' . 来源: https://stackoverflow.com/questions/18133264/how

PyLint not recognizing cv2 members

巧了我就是萌 提交于 2019-11-27 13:34:44
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 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-rcfile > .pylintrc At the beginning of the generated .pylintrc file you will see # A comma-separated list

How to configure PyLint to check all things PEP8 checks?

落花浮王杯 提交于 2019-11-27 12:48:58
问题 Searching for an answer on PyLint's mailing list brings no interesting results. PyLint is known to be very customizable so I guess this should be possible... The reason I would like PyLint to check compliance with PEP8 is because PyDev has much better support for PyLint than it has for PEP8. It's easier to have one tool doing all checks than having to use two. I also asked this question on PyLint's mailing list at http://thread.gmane.org/gmane.comp.python.logilab/1039 Example of diagnostic

How to fix pylint logging-not-lazy? [duplicate]

五迷三道 提交于 2019-11-27 12:37:50
问题 This question already has an answer here: PyLint message: logging-format-interpolation 2 answers I am using prospector to examine my code. Pylint returned a logging-not-lazy warning about my debug message. Line: 31 pylint: logging-not-lazy / Specify string format arguments as logging function parameters (col 16) Line: 42 pylint: logging-not-lazy / Specify string format arguments as logging function parameters (col 12) My code is: logging.debug("detect mimetypes faild because %s" % e ) How do

How do I tell PyLint “it's a variable, not a constant” to stop message C0103?

落爺英雄遲暮 提交于 2019-11-27 11:37:47
问题 I have a module-level variable in my Python 2.6 program named "_log", which PyLint complains about: C0103: Invalid name "_log" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$) Having read this answer I understand why it's doing this: it thinks the variable is a constant and applies the constant regex. However, I beg to differ: I think it's a variable. How do I tell PyLint that, so it doesn't complain? How does PyLint determine whether it's a variable or a constant - does it just treat all module

How do I create a pylintrc file

人盡茶涼 提交于 2019-11-27 11:37:24
I am running linux. Can I do something like pylint --generate-rcfile > .pylintrc and then make changes to the resulting .pylintrc file to override the default settings? And if so should it be in my ~/ directory or should I put it in .pylint.d? You may put it in: /etc/pylintrc for default global configuration ~/.pylintrc for default user configuration <your project>/pylintrc for default project configuration (used when you'll run pylint <your project> ) wherever you want, then use pylint --rcfile=<wherever I want> Also notice when generating the rc file, you may add option on the command line