pylint

In pylint is there a way to locally disable a warning and then undo the previous suppression without explicitly giving a list?

こ雲淡風輕ζ 提交于 2019-12-12 12:27:32
问题 I am aware of the FAQ entry for PyLint which states that: 4.2 Is there a way to disable a message for a particular module only? Yes, you can disable or enable (globally disabled) messages at the module level by adding the corresponding option in a comment at the top of the file: # pylint: disable=wildcard-import, method-hidden # pylint: enable=too-many-lines However, how can I locally suppress a message and then simply restore the previous state, prior to suppression. I don't want to have to

Nose tools and pylint

核能气质少年 提交于 2019-12-12 10:54:35
问题 What is the right way to use nose.tools and keep pylint happy? The following code: ''' This is a test ''' import nose.tools import nose.tools.trivial nose.tools.assert_equal(1, 1) nose.tools.assert_equals(1, 1) nose.tools.trivial.assert_equal(1, 1) nose.tools.trivial.assert_equals(1, 1) Results in the following pylint errors: $ pylint -i y -r n /tmp/aseq.py ************* Module aseq E1101: 8,0: Module 'nose.tools' has no 'assert_equal' member E1101: 9,0: Module 'nose.tools' has no 'assert

pylint, coroutines, decorators and type inferencing

拜拜、爱过 提交于 2019-12-12 10:07:04
问题 I'm working on a Google AppEngine project and I recently upgraded my pylint version to: No config file found, using default configuration pylint 1.5.6, astroid 1.4.6 Python 2.7.10 (default, Oct 23 2015, 19:19:21) This seems to have broken some type inferencing. Specifically, GAE's ndb uses a decorator and a generator function to return a "Future" object like this: @ndb.tasklet def coroutine_like(item_id): # do something here... item = yield EntityType.get_by_id_async(item_id) raise ndb.Return

Hide some maybe-no-member Pylint errors

纵饮孤独 提交于 2019-12-12 09:31:08
问题 The following Python fragment code gets analyzed by Pylint : if type(result) is array.array: read = result.tobytes() ... with the following error for the last line: E:401,22: Instance of 'int' has no 'tobytes' member\ (but some types could not be inferred) (maybe-no-member) The result variable is received from an external function. How can I change (correct) the code to make Pylint understand? Or how can I tell it that the result of the function can have other types than int? Or how can I

Disable warning message of pylint

我与影子孤独终老i 提交于 2019-12-12 01:10:09
问题 Checking code with pylint shows so many messages about variable names as follows: Invalid name "getCurrentChannel" for type method (should match [a-z_][a-z0-9_]{2,30}$) How can I disable these messages ? 回答1: pylint --disable=C0103 filename Running this command will not show messages for "Invalid variable name". 来源: https://stackoverflow.com/questions/21778497/disable-warning-message-of-pylint

Set multiple inferred types based on arguments for pylint plugin

女生的网名这么多〃 提交于 2019-12-11 16:15:42
问题 I have a class that implements some typechecking via class variables. Then, when the class is instantiated, the defined variables become required arguments for the class, with required types. The pattern looks something like this: class MyClass(MagicBaseClass): arg1 = ArgumentObj(allowedTypes=(basestring, )) arg2 = ArgumentObj(allowedTypes=(list, tuple)) def myMethod(self): print type(self.arg1) # a basestring print type(self.arg2) # a list mc = MyClass(arg1='test', arg2=()) mc.myMethod()

How can I use pyreverse in Eclipse?

穿精又带淫゛_ 提交于 2019-12-11 10:58:49
问题 I've installed Eclipse (latest stable) and integrated PyDev and PyLint succesfully. Now being a python noob I wonder if I could somehow get an UML sheme from within Eclipse to do some reverse engineering of existing python code. Thanks for your time guys! 回答1: I don't think that pylint includes a way to get at the pyreverse features from within eclipse. You can try getting the UML outside Eclipse, or another plugin like http://sourceforge.net/projects/eclipse-pyuml/ 回答2: Due to lack of

How to remove unused function parameters in shutil.rmtree

為{幸葍}努か 提交于 2019-12-11 06:07:56
问题 In this question, an answer to how to remove read-only files is presented. It's super effective but requires having unused parameters. In this other question it was asked how to tell pylint that multiple non-adjacent parameters are unused without adding a specific comment (e.g., by using _ ). Many of the answers were approximately "ZOMG YOU'RE DESIGNING IT WRONG" so I promised I would put up an example where this is needed and out of my control. Here is that example. shutil.rmtree(self._temp

Pylint with pytorch: Is there a way to tell pylint to look for module in different place?

痴心易碎 提交于 2019-12-11 04:54:09
问题 I am using pytorch and pylint does not recognize few functions for ex: torch.stack however, if I do import torch._C as torch it seems to work fine. If I do above, actual modules that exist inside torch package like torch.cuda or torch.nn need to imported individually as simply doing torch.cuda would point to torch._C.cuda and hence won't work. Is there a way to tell pylint to look at both torch and torch._C when I do import torch or even whenever it sees torch? I don't think I would use torch

Restricting py.test to only run pylint and not unittests

為{幸葍}努か 提交于 2019-12-11 04:47:51
问题 I'm trying to run py.test and execute only pylint, but not unittests. The documentation on this page indicates you can do it: https://pypi.org/project/pytest-pylint/ You can restrict your test run to only perform pylint checks and not any other tests by typing: py.test --pylint -m pylint But when I run that command exactly I still get errors from unittests that py.test found. The linting process seems to run as expected, then I get a bunch of errors in unittest files reported. This seems