From mabelang at ciena.com Fri Sep 4 22:20:18 2015 From: mabelang at ciena.com (Belanger, Martin) Date: Fri, 4 Sep 2015 13:20:18 -0700 Subject: [code-quality] pylint reports false errors if I define a class with the name "Enumeration" Message-ID: I'm using this version of pylint: pylint 1.3.1, astroid 1.2.1, common 0.62.0 Python 2.7.9 (default, Apr 2 2015, 15:33:21) When I run pylint over the code below I get the error message: "E: 9, 0: Instance of 'MY_ENUM' has no 'blah' member (no-member)". class Enumeration(object): def __init__(self, name, enum_list): pass def blah(self): pass my_enum = Enumeration('MY_ENUM', [("disable", 0), ("enable", 1)]) my_enum.blah() I can fix this error by enclosing [("disable", 0), ("enable", 1)] inside a list() or tuple(). In other words, the following fixes the problem: my_enum = Enumeration('MY_ENUM', *list*([("disable", 0), ("enable", 1)])) Any thoughts? Thanks, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From pcmanticore at gmail.com Sat Sep 5 16:26:18 2015 From: pcmanticore at gmail.com (Claudiu Popa) Date: Sat, 5 Sep 2015 17:26:18 +0300 Subject: [code-quality] pylint reports false errors if I define a class with the name "Enumeration" In-Reply-To: References: Message-ID: On Fri, Sep 4, 2015 at 11:20 PM, Belanger, Martin wrote: > I'm using this version of pylint: > > pylint 1.3.1, > astroid 1.2.1, common 0.62.0 > Python 2.7.9 (default, Apr 2 2015, 15:33:21) > > > When I run pylint over the code below I get the error message: "E: 9, 0: > Instance of 'MY_ENUM' has no 'blah' member (no-member)". > > class Enumeration(object): > def __init__(self, name, enum_list): > pass > > def blah(self): > pass > > my_enum = Enumeration('MY_ENUM', [("disable", 0), ("enable", 1)]) > my_enum.blah() > > > I can fix this error by enclosing [("disable", 0), ("enable", 1)] inside a > list() or tuple(). In other words, the following fixes the problem: > > my_enum = Enumeration('MY_ENUM', list([("disable", 0), ("enable", 1)])) > > Any thoughts? > > Thanks, > Martin > > _______________________________________________ > code-quality mailing list > code-quality at python.org > https://mail.python.org/mailman/listinfo/code-quality > Oups, this was ugly. I fixed it in astroid 1.4.0, with https://bitbucket.org/logilab/astroid/commits/1bb9d1375f71e2ed47169982050d679ea190a29f. Thank you for the report! /Claudiu From rbhattacharjee at dataxu.com Mon Sep 21 19:55:17 2015 From: rbhattacharjee at dataxu.com (Rohit Bhattacharjee) Date: Mon, 21 Sep 2015 17:55:17 +0000 Subject: [code-quality] pylint duplicate code warning Message-ID: Hi, I am facing an issue with Pylint duplicate-code warning and need some help. I want to disable the duplicate-code warning because I expect some pieces of code to be duplicated, but I am unable to suppress the pylint warning. Still now I have tried # pylint: disable=duplicate-code. Thanks in advance Rohit -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at the-compiler.org Tue Sep 22 06:22:03 2015 From: me at the-compiler.org (Florian Bruhin) Date: Tue, 22 Sep 2015 06:22:03 +0200 Subject: [code-quality] pylint duplicate code warning In-Reply-To: References: Message-ID: <20150922042203.GB10374@tonks> * Rohit Bhattacharjee [2015-09-21 17:55:17 +0000]: > Hi, > > I am facing an issue with Pylint duplicate-code warning and need some help. > > I want to disable the duplicate-code warning because I expect some pieces of code to be duplicated, but I am unable to suppress the pylint warning. > > Still now I have tried # pylint: disable=duplicate-code. You got an answer in IRC yesterday: I think there's an issue about this. https://bitbucket.org/logilab/pylint/issues/214/the-duplicate-code-r0801-cant-be-disabled [ http://cmpl.cc:8888/c06 ] Probably related Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc I love long mails! | http://email.is-not-s.ms/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From okko.willeboordse at gmail.com Tue Sep 22 21:30:28 2015 From: okko.willeboordse at gmail.com (Okko Willeboordse) Date: Tue, 22 Sep 2015 21:30:28 +0200 Subject: [code-quality] psutil import error Message-ID: import psutil Gives; [F0401] Unable to import 'psutil' pylint 1.4.4, astroid 1.3.8, common 1.0.2 Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at the-compiler.org Wed Sep 23 12:29:21 2015 From: me at the-compiler.org (Florian Bruhin) Date: Wed, 23 Sep 2015 12:29:21 +0200 Subject: [code-quality] psutil import error In-Reply-To: References: Message-ID: <20150923102921.GE30194@tonks> * Okko Willeboordse [2015-09-22 21:30:28 +0200]: > import psutil > > Gives; [F0401] Unable to import 'psutil' Works fine here: $ virtualenv .venv2 Running virtualenv with interpreter /usr/bin/python2 New python executable in .venv2/bin/python2 Also creating executable in .venv2/bin/python Installing setuptools, pip...done. $ source .venv2/bin/activate $ pip install psutil pylint Downloading/unpacking pylint Downloading pylint-1.4.4-py2.py3-none-any.whl (428kB): 428kB downloaded Downloading/unpacking psutil Downloading psutil-3.2.1.tar.gz (251kB): 251kB downloaded [...] Downloading/unpacking six (from pylint) Downloading six-1.9.0-py2.py3-none-any.whl Downloading/unpacking astroid>=1.3.6 (from pylint) Downloading astroid-1.3.8-py2.py3-none-any.whl (183kB): 183kB downloaded Downloading/unpacking logilab-common>=0.53.0 (from pylint) Downloading logilab-common-1.0.2.tar.gz (190kB): 190kB downloaded [...] $ echo 'import psutil' > foo.py $ pylint foo.py -rn No config file found, using default configuration ************* Module foo C: 1, 0: Black listed name "foo" (blacklisted-name) C: 1, 0: Missing module docstring (missing-docstring) W: 1, 0: Unused import psutil (unused-import) It sounds like the python your pylint is installed for doesn't have the psutil package (e.g. because you run your code in a virtualenv typically, but use a system-wide pylint package). Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc I love long mails! | http://email.is-not-s.ms/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From me at the-compiler.org Wed Sep 23 16:27:18 2015 From: me at the-compiler.org (Florian Bruhin) Date: Wed, 23 Sep 2015 16:27:18 +0200 Subject: [code-quality] psutil import error In-Reply-To: References: <20150923102921.GE30194@tonks> Message-ID: <20150923142718.GF30194@tonks> * Okko Willeboordse [2015-09-23 15:51:17 +0200]: > Note that I run on Windows, you don't (/usr/bin/python2). Also works fine for me under Windows. > Also note that programs using psutil run fine. That'd suggest the same - the Python your pylint is installed for isn't the Python you're running. > C:\Users\owillebo>python > Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import psutil > >>> Can you do 'import pylint' here? Can you test with python -m pylint instead? Florian -- http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc I love long mails! | http://email.is-not-s.ms/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From okko.willeboordse at gmail.com Wed Sep 23 15:51:17 2015 From: okko.willeboordse at gmail.com (Okko Willeboordse) Date: Wed, 23 Sep 2015 15:51:17 +0200 Subject: [code-quality] psutil import error In-Reply-To: <20150923102921.GE30194@tonks> References: <20150923102921.GE30194@tonks> Message-ID: Note that I run on Windows, you don't (/usr/bin/python2). Also note that programs using psutil run fine. Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\owillebo>python Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import psutil >>> C:\Users\owillebo>echo import psutil > test.py C:\Users\owillebo>pylint test.py No config file found, using default configuration ************* Module test C: 1, 0: Trailing whitespace (trailing-whitespace) C: 1, 0: Missing module docstring (missing-docstring) F: 1, 0: Unable to import 'psutil' (import-error) W: 1, 0: Unused import psutil (unused-import) .... On Wed, Sep 23, 2015 at 12:29 PM, Florian Bruhin wrote: > * Okko Willeboordse [2015-09-22 21:30:28 +0200]: >> import psutil >> >> Gives; [F0401] Unable to import 'psutil' > > Works fine here: > > $ virtualenv .venv2 > Running virtualenv with interpreter /usr/bin/python2 > New python executable in .venv2/bin/python2 > Also creating executable in .venv2/bin/python > Installing setuptools, pip...done. > > $ source .venv2/bin/activate > > $ pip install psutil pylint > Downloading/unpacking pylint > Downloading pylint-1.4.4-py2.py3-none-any.whl (428kB): 428kB downloaded > Downloading/unpacking psutil > Downloading psutil-3.2.1.tar.gz (251kB): 251kB downloaded > [...] > Downloading/unpacking six (from pylint) > Downloading six-1.9.0-py2.py3-none-any.whl > Downloading/unpacking astroid>=1.3.6 (from pylint) > Downloading astroid-1.3.8-py2.py3-none-any.whl (183kB): 183kB downloaded > Downloading/unpacking logilab-common>=0.53.0 (from pylint) > Downloading logilab-common-1.0.2.tar.gz (190kB): 190kB downloaded > [...] > > $ echo 'import psutil' > foo.py > > $ pylint foo.py -rn > No config file found, using default configuration > ************* Module foo > C: 1, 0: Black listed name "foo" (blacklisted-name) > C: 1, 0: Missing module docstring (missing-docstring) > W: 1, 0: Unused import psutil (unused-import) > > It sounds like the python your pylint is installed for doesn't have > the psutil package (e.g. because you run your code in a virtualenv > typically, but use a system-wide pylint package). > > Florian > > -- > http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP) > GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc > I love long mails! | http://email.is-not-s.ms/