From barry at python.org Wed Feb 1 01:16:12 2017 From: barry at python.org (Barry Warsaw) Date: Wed, 1 Feb 2017 01:16:12 -0500 Subject: [code-quality] Unable to import 'os' (import-error) References: <784c0c7f-9f52-344c-f8e4-8082424e764d@icloud.com> Message-ID: <20170201011612.1bb70678@subdivisions.wooz.org> On Jan 31, 2017, at 08:29 AM, Bill D wrote: >$ cat li.py >#!/usr/bin/env python ^^^^^^^^^^^^^^^^^^^^^^ >"""foobar""" >import os >print os.listdir(os.curdir) > >$ /usr/local/bin//pylint --version ^^^^^^^^^^^^^^^^^^^^^^^^^ It could be you're mixing up your Python interpreter and runtimes. E.g. running a different 'python' than /usr/bin/python because it's earlier on your $PATH, or picking up some misconfigured /usr/local/bin/python that doesn't have its stdlib installed correctly. Try narrowing it down with only packages from the Ubuntu archive. Cheers, -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 801 bytes Desc: OpenPGP digital signature URL: From maxfischer2781 at gmail.com Mon Feb 27 05:12:22 2017 From: maxfischer2781 at gmail.com (Max Fischer) Date: Mon, 27 Feb 2017 11:12:22 +0100 Subject: [code-quality] pylint syntax-error for compatibility code Message-ID: Hi all, I am having problems disabling the pylint `syntax-error` for compatibility code. Basically, I have a compatibility sub-package [1] that tries importing different variants of code until it does not hit SyntaxError. There are other projects where I do the same. I have found a bug report on a similar issue [2] but it was closed. Pylint is having a hard time with this approach. When I run the check with python3, all python2-only code produces syntax-error. It is not possible to disable this error with either `# pylint: skip-file` or `# pylint: disable=syntax-error` at the start of the file. I don't want to ignore compatibility code per se, as it tends to collect quite a lot of code smell. Since it is a severe error requiring action under most circumstances, I don't want a mental "just ignore syntax-error" to be a required for reading reports. Is there a way to get pylint to play nice with compatibility code? Can I refactor my code to play nicer with pylint? Cheers, Max [1] https://github.com/maxfischer2781/chainlet/blob/master/chainlet/compat/__init__.py [2] disable=syntax-error doesn't work #986 https://github.com/PyCQA/pylint/issues/986 From strombrg at gmail.com Mon Feb 27 21:32:57 2017 From: strombrg at gmail.com (Dan Stromberg) Date: Mon, 27 Feb 2017 18:32:57 -0800 Subject: [code-quality] pylint syntax-error for compatibility code In-Reply-To: References: Message-ID: Hi Max. I'm not 100% sure I know all the specifics of what you're asking, but you could try: http://stromberg.dnsalias.org/~strombrg/this-pylint/ It makes it so you can ignore errors that pylint does not allow you to otherwise turn off. It also attempts to give a meaningful exit status for use in automation. HTH On Mon, Feb 27, 2017 at 2:12 AM, Max Fischer wrote: > Hi all, > > I am having problems disabling the pylint `syntax-error` for compatibility > code. > Basically, I have a compatibility sub-package [1] that tries importing > different variants of code until it does not hit SyntaxError. There are > other projects where I do the same. > I have found a bug report on a similar issue [2] but it was closed. > > Pylint is having a hard time with this approach. When I run the check with > python3, all python2-only code produces syntax-error. It is not possible to > disable this error with either `# pylint: skip-file` or `# pylint: > disable=syntax-error` at the start of the file. > I don't want to ignore compatibility code per se, as it tends to collect > quite a lot of code smell. Since it is a severe error requiring action > under most circumstances, I don't want a mental "just ignore syntax-error" > to be a required for reading reports. > > Is there a way to get pylint to play nice with compatibility code? Can I > refactor my code to play nicer with pylint? > > Cheers, > Max > > [1] > https://github.com/maxfischer2781/chainlet/blob/ > master/chainlet/compat/__init__.py > > [2] disable=syntax-error doesn't work #986 > https://github.com/PyCQA/pylint/issues/986 > _______________________________________________ > code-quality mailing list > code-quality at python.org > https://mail.python.org/mailman/listinfo/code-quality > -- Dan Stromberg -------------- next part -------------- An HTML attachment was scrubbed... URL: From me at the-compiler.org Tue Feb 28 17:11:52 2017 From: me at the-compiler.org (Florian Bruhin) Date: Tue, 28 Feb 2017 23:11:52 +0100 Subject: [code-quality] Getting progress output? In-Reply-To: References: Message-ID: <20170228221152.523espdrdtbaibe5@tonks> Hey, * Chris Spencer [2017-01-19 10:45:53 -0500]: > Is there any way to configure Pylint to report progress? Nothing fancy, > just something like "Processing file 4 of 104..." Sorry for the late answer to this! There's no way to do this currently, and I'd actually like something similar. It wouldn't be too hard - this is a start: diff --git a/pylint/lint.py b/pylint/lint.py index 258bfdc3..30bac9f1 100644 --- a/pylint/lint.py +++ b/pylint/lint.py @@ -839,6 +839,8 @@ class PyLinter(config.OptionsManagerMixIn, if not self.should_analyze_file(modname, filepath, is_argument=is_arg): continue + print(modname) + self.set_current_module(modname, filepath) # get the module representation ast_node = self.get_ast(filepath, modname) However I never got around to making this a proper option and turning it into a PR... 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: 833 bytes Desc: not available URL: