Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36530 > unrolled thread
| Started by | jkn <jkn_gg@nicorp.f9.co.uk> |
|---|---|
| First post | 2013-01-09 15:45 -0800 |
| Last post | 2013-01-11 00:35 -0800 |
| Articles | 10 — 8 participants |
Back to article view | Back to comp.lang.python
pylint or similar to test version-specific language constructs? jkn <jkn_gg@nicorp.f9.co.uk> - 2013-01-09 15:45 -0800
Re: pylint or similar to test version-specific language constructs? Gisle Vanem <gvanem@broadpark.no> - 2013-01-10 01:07 +0100
Re: pylint or similar to test version-specific language constructs? The Night Tripper <jkn+gg@nicorp.co.uk> - 2013-01-11 08:29 +0000
Re: pylint or similar to test version-specific language constructs? Terry Reedy <tjreedy@udel.edu> - 2013-01-11 08:38 -0500
Re: pylint or similar to test version-specific language constructs? Dave Angel <d@davea.name> - 2013-01-11 10:06 -0500
Re: pylint or similar to test version-specific language constructs? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-11 15:37 +0000
Re: pylint or similar to test version-specific language constructs? Dave Angel <d@davea.name> - 2013-01-11 11:09 -0500
Re: pylint or similar to test version-specific language constructs? jkn <jkn_gg@nicorp.f9.co.uk> - 2013-01-13 09:56 -0800
Re: pylint or similar to test version-specific language constructs? Chris Angelico <rosuav@gmail.com> - 2013-01-14 07:59 +1100
Re: pylint or similar to test version-specific language constructs? thenault@gmail.com - 2013-01-11 00:35 -0800
| From | jkn <jkn_gg@nicorp.f9.co.uk> |
|---|---|
| Date | 2013-01-09 15:45 -0800 |
| Subject | pylint or similar to test version-specific language constructs? |
| Message-ID | <1454e34f-5ca0-4f49-ad29-c99df4fdd322@gu9g2000vbb.googlegroups.com> |
Hi all
I have to write python code which must run on an old version of
python (v2.4) as well as a newer (v2.7). I am using pylint and would
like to check if is possible to check with pylint the use of operators
etc. which are not present in 2.4; the ternary operator springs to
mind.
I haven't found anything in pylint which indicates it can do this sort
of check; am I missing anything? Other suggestions for this kind of
checking welcome.
Thanks
Jon N
[toc] | [next] | [standalone]
| From | Gisle Vanem <gvanem@broadpark.no> |
|---|---|
| Date | 2013-01-10 01:07 +0100 |
| Message-ID | <mailman.349.1357776502.2939.python-list@python.org> |
| In reply to | #36530 |
"jkn" <jkn_gg@nicorp.f9.co.uk> wrote: > I have to write python code which must run on an old version of > python (v2.4) as well as a newer (v2.7). I am using pylint and would > like to check if is possible to check with pylint the use of operators > etc. which are not present in 2.4; the ternary operator springs to > mind. No idea about PyLint. Why not install Python 2.4 and test with that? Sounds safer IMHO. -gv
[toc] | [prev] | [next] | [standalone]
| From | The Night Tripper <jkn+gg@nicorp.co.uk> |
|---|---|
| Date | 2013-01-11 08:29 +0000 |
| Message-ID | <QeednQoFKKHXUHLNnZ2dnUVZ8gadnZ2d@brightview.co.uk> |
| In reply to | #36535 |
Gisle Vanem wrote:
> "jkn" <jkn_gg@nicorp.f9.co.uk> wrote:
>
>> I have to write python code which must run on an old version of
>> python (v2.4) as well as a newer (v2.7). I am using pylint and would
>> like to check if is possible to check with pylint the use of operators
>> etc. which are not present in 2.4; the ternary operator springs to
>> mind.
>
> No idea about PyLint. Why not install Python 2.4 and test
> with that? Sounds safer IMHO.
I do have Python 2.4 installed; but I would like a checker that warned me
beforehand about trying to use constructs (like the ternary operator,
decorators) which are version-specific.
J^n
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-01-11 08:38 -0500 |
| Message-ID | <mailman.397.1357911591.2939.python-list@python.org> |
| In reply to | #36608 |
On 1/11/2013 3:29 AM, The Night Tripper wrote: > Gisle Vanem wrote: > >> "jkn" <jkn_gg@nicorp.f9.co.uk> wrote: >> >>> I have to write python code which must run on an old version of >>> python (v2.4) as well as a newer (v2.7). I am using pylint and would >>> like to check if is possible to check with pylint the use of operators >>> etc. which are not present in 2.4; the ternary operator springs to >>> mind. >> >> No idea about PyLint. Why not install Python 2.4 and test >> with that? Sounds safer IMHO. > > I do have Python 2.4 installed; but I would like a checker that warned me > beforehand about trying to use constructs (like the ternary operator, > decorators) which are version-specific. Search each chapter of the reference manual (about 7) for 'version changed'. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2013-01-11 10:06 -0500 |
| Message-ID | <mailman.401.1357916818.2939.python-list@python.org> |
| In reply to | #36608 |
On 01/11/2013 03:29 AM, The Night Tripper wrote: > Gisle Vanem wrote: > >> "jkn" <jkn_gg@nicorp.f9.co.uk> wrote: >> >>> I have to write python code which must run on an old version of >>> python (v2.4) as well as a newer (v2.7). I am using pylint and would >>> like to check if is possible to check with pylint the use of operators >>> etc. which are not present in 2.4; the ternary operator springs to >>> mind. >> No idea about PyLint. Why not install Python 2.4 and test >> with that? Sounds safer IMHO. > I do have Python 2.4 installed; but I would like a checker that warned me > beforehand about trying to use constructs (like the ternary operator, > decorators) which are version-specific. > > J^n > Not sure what you mean by beforehand. Don't you run all your unit tests before putting each revision of your code into production? So run those tests twice, once on 2.7, and once on 2.4. A unit test that's testing code with a ternary operator will fail, without any need for a separate test. if it doesn't, then you've got some coverage gaps in your unit tests. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-01-11 15:37 +0000 |
| Message-ID | <50f031b5$0$30003$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #36626 |
On Fri, 11 Jan 2013 10:06:30 -0500, Dave Angel wrote: > On 01/11/2013 03:29 AM, The Night Tripper wrote: >> Gisle Vanem wrote: >> >>> "jkn" <jkn_gg@nicorp.f9.co.uk> wrote: >>> >>>> I have to write python code which must run on an old version of >>>> python (v2.4) as well as a newer (v2.7). I am using pylint and would >>>> like to check if is possible to check with pylint the use of >>>> operators etc. which are not present in 2.4; the ternary operator >>>> springs to mind. >>> No idea about PyLint. Why not install Python 2.4 and test with that? >>> Sounds safer IMHO. >> I do have Python 2.4 installed; but I would like a checker that warned >> me beforehand about trying to use constructs (like the ternary >> operator, decorators) which are version-specific. Decorators work fine in Python 2.4. > Not sure what you mean by beforehand. Don't you run all your unit tests > before putting each revision of your code into production? So run those > tests twice, once on 2.7, and once on 2.4. A unit test that's testing > code with a ternary operator will fail, without any need for a separate > test. You don't even need tests for the code that includes the ternary operator. The module simply won't compile in Python 2.4, you get a SyntaxError when you try to import it or run it. You don't need PyLint to check for *illegal syntax*. Python already does that. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <d@davea.name> |
|---|---|
| Date | 2013-01-11 11:09 -0500 |
| Message-ID | <mailman.404.1357920575.2939.python-list@python.org> |
| In reply to | #36628 |
On 01/11/2013 10:37 AM, Steven D'Aprano wrote: > On Fri, 11 Jan 2013 10:06:30 -0500, Dave Angel wrote: > >> <snip> > >> Not sure what you mean by beforehand. Don't you run all your unit tests >> before putting each revision of your code into production? So run those >> tests twice, once on 2.7, and once on 2.4. A unit test that's testing >> code with a ternary operator will fail, without any need for a separate >> test. > You don't even need tests for the code that includes the ternary > operator. The module simply won't compile in Python 2.4, you get a > SyntaxError when you try to import it or run it. > > You don't need PyLint to check for *illegal syntax*. Python already does > that. > You're right of course. But I can weasel out of it by saying that Python will only check it if the particular module is imported. I've seen equivalent bugs in real projects, where a release went out with one of its dynamic libraries not even present. Another thing that can stop Python from checking is if some naive programmer uses a bare except in production code. Both of these would show up in the simplest of unit testing code. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | jkn <jkn_gg@nicorp.f9.co.uk> |
|---|---|
| Date | 2013-01-13 09:56 -0800 |
| Message-ID | <fc8295cd-e226-42e5-ad1e-ddc81a5303a3@c14g2000vbd.googlegroups.com> |
| In reply to | #36626 |
Hi Dave
On 11 Jan, 15:06, Dave Angel <d...@davea.name> wrote:
>
> Not sure what you mean by beforehand. Don't you run all your unit tests
> before putting each revision of your code into production? So run those
> tests twice, once on 2.7, and once on 2.4. A unit test that's testing
> code with a ternary operator will fail, without any need for a separate
> test.
>
> if it doesn't, then you've got some coverage gaps in your unit tests.
By 'beforehand' I meant 'before testing on my target 2.4 system;
perhaps I should have been clearer in that I am running 2.7 on my
'development' platform, and 2.4 on my target. It would be painful to
put 2.4 on my target system (although I continue to wonder about
that...). So I was looking to catch such errors before migrating to
the target.
[Steven D'Aprano]
> Decorators work fine in Python 2.4.
Yes, I was just coming up with another example of a language construct
which didn't exist at one point.
> You don't even need tests for the code that includes the ternary
> operator. The module simply won't compile in Python 2.4, you get a
> SyntaxError when you try to import it or run it.
In fact I had a misapprehension about this; for some reason (I thought
I'd tried it) I thought such an error only got caught at runtime, not
'compile-time'. I now see that this is not the case, which means the
athe problem is less of a concern than I thought.
Thanks for the comments.
Jon N
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-01-14 07:59 +1100 |
| Message-ID | <mailman.479.1358110759.2939.python-list@python.org> |
| In reply to | #36744 |
On Mon, Jan 14, 2013 at 4:56 AM, jkn <jkn_gg@nicorp.f9.co.uk> wrote: > Hi Dave > > On 11 Jan, 15:06, Dave Angel <d...@davea.name> wrote: >> >> Not sure what you mean by beforehand. Don't you run all your unit tests >> before putting each revision of your code into production? So run those >> tests twice, once on 2.7, and once on 2.4. A unit test that's testing >> code with a ternary operator will fail, without any need for a separate >> test. >> >> if it doesn't, then you've got some coverage gaps in your unit tests. > > By 'beforehand' I meant 'before testing on my target 2.4 system; > perhaps I should have been clearer in that I am running 2.7 on my > 'development' platform, and 2.4 on my target. It would be painful to > put 2.4 on my target system (although I continue to wonder about > that...). So I was looking to catch such errors before migrating to > the target. Painful to put 2.4 on your dev, you mean? I've never done it, but I would expect that the old sources will compile against newer libraries with no problems. That's likely to be the easiest option. It's the language-level equivalent of watching for a thrown exception rather than asking forgiveness beforehand :) ChrisA
[toc] | [prev] | [next] | [standalone]
| From | thenault@gmail.com |
|---|---|
| Date | 2013-01-11 00:35 -0800 |
| Message-ID | <259c43d5-d740-402f-8e8a-b427336854e5@googlegroups.com> |
| In reply to | #36530 |
On Thursday, January 10, 2013 12:45:32 AM UTC+1, jkn wrote: > Hi all > > I have to write python code which must run on an old version of > > python (v2.4) as well as a newer (v2.7). I am using pylint and would > > like to check if is possible to check with pylint the use of operators > > etc. which are not present in 2.4; the ternary operator springs to > > mind. > > > > I haven't found anything in pylint which indicates it can do this sort > > of check; am I missing anything? Other suggestions for this kind of > > checking welcome. Hi, there is no such checker in pylint yet, though it should be fairly easy to build one. The longer part being to identify all constructs that should be detected and their representation in the ast. Then pylint checkers are simple visitors. You'll get some help from the project mailing list (python-projects@lists.logilab.org) if you go that way. Regards, -- Sylvain
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web