470,826 Members | 1,942 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,826 developers. It's quick & easy.

Pychecker

Howdy, I had the impression that pychecker caught and reported such
dynamic syntactical errors.

#!/usr/bin/env python
def add(i):
i += 10

status = 3

if 1 == 1:
statuss = 15

add(status)

=======================

exalted sysfault$ pychecker foo.py
Processing foo...

Warnings...

None

=======================

Hence the mispelling of status (statuss), which was done purposely to test
if pychecker will acknowledge and report the error. Do i need to enable
some type of pychecker option in order for it to pick up the error? I know
that it is syntactically correct in python, however it's likely that
'status' is meant. Am i wishing that pychecker will replace a statically
typed language mechanism?

--
A wise man knows he knows nothing.

Jun 9 '06 #1
4 1802
Anthony Greene <sy******@zetafunc.net> wrote in
news:pa****************************@zetafunc.net:
Howdy, I had the impression that pychecker caught and reported such
dynamic syntactical errors.

#!/usr/bin/env python
def add(i):
i += 10

status = 3

if 1 == 1:
statuss = 15

add(status)

=======================

exalted sysfault$ pychecker foo.py
Processing foo...

Warnings...

None

=======================

Hence the mispelling of status (statuss), which was done purposely to
test if pychecker will acknowledge and report the error. Do i need to
enable some type of pychecker option in order for it to pick up the
error? I know that it is syntactically correct in python, however it's
likely that 'status' is meant. Am i wishing that pychecker will
replace a statically typed language mechanism?


I think you're asking a lot from pychecker.

kop = 1
koi = 2

if True:
koo = 3

What would you like pychecker to report?
--
rzed

Jun 9 '06 #2
Anthony Greene wrote:
Howdy, I had the impression that pychecker caught and reported such
dynamic syntactical errors.

#!/usr/bin/env python
def add(i):
i += 10

status = 3

if 1 == 1:
statuss = 15

add(status)

=======================

exalted sysfault$ pychecker foo.py
Processing foo...

Warnings...

None

=======================

Hence the mispelling of status (statuss), which was done purposely to test
if pychecker will acknowledge and report the error. Do i need to enable
some type of pychecker option in order for it to pick up the error? I know
that it is syntactically correct in python, however it's likely that
'status' is meant. Am i wishing that pychecker will replace a statically
typed language mechanism?


That's a functional error, not a syntactical one. Analyzing the
spelling of variables for similarity would lead to a lot of incorrect
warnings since pychecker has no way to tell this apart from intentional
similar spellings such as:

values = [1, 2, 3]
value = values[0]

However, when the misspelling is made inside a local scope, rather than
at the module level a warning is reported "test.py:8: Local variable
(statuss) not used":

def add(i):
i += 10

def test():
status = 3
if 1 == 1:
statuss = 15
add(status)
This is why tools like pychecker (or pyflakes, pylint, or even a static
code compiler) aren't a substitute for unit tests. They can definitely
help catch common mistakes, but they can't ensure your code does what
you intended.

--
Matt Good

Jun 9 '06 #3

Rick> I think you're asking a lot from pychecker.

Rick> kop = 1
Rick> koi = 2

Rick> if True:
Rick> koo = 3

Rick> What would you like pychecker to report?

I thing the OP was hoping for a "not used" error, but it can only reasonably
do that within a function, which it does do:

pyc.py:2: Local variable (kop) not used
pyc.py:3: Local variable (koi) not used
pyc.py:6: Local variable (koo) not used

At the module level it doesn't know that the suspect object isn't accessed
from another module.

Skip
Jun 9 '06 #4
On Fri, 09 Jun 2006 11:46:59 -0700, Matt Good wrote:
Anthony Greene wrote:
Howdy, I had the impression that pychecker caught and reported such
dynamic syntactical errors.

#!/usr/bin/env python
def add(i):
i += 10

status = 3

if 1 == 1:
statuss = 15

add(status)

=======================

exalted sysfault$ pychecker foo.py
Processing foo...

Warnings...

None

=======================

Hence the mispelling of status (statuss), which was done purposely to test
if pychecker will acknowledge and report the error. Do i need to enable
some type of pychecker option in order for it to pick up the error? I know
that it is syntactically correct in python, however it's likely that
'status' is meant. Am i wishing that pychecker will replace a statically
typed language mechanism?


That's a functional error, not a syntactical one. Analyzing the
spelling of variables for similarity would lead to a lot of incorrect
warnings since pychecker has no way to tell this apart from intentional
similar spellings such as:

values = [1, 2, 3]
value = values[0]

However, when the misspelling is made inside a local scope, rather than
at the module level a warning is reported "test.py:8: Local variable
(statuss) not used":

def add(i):
i += 10

def test():
status = 3
if 1 == 1:
statuss = 15
add(status)
This is why tools like pychecker (or pyflakes, pylint, or even a static
code compiler) aren't a substitute for unit tests. They can definitely
help catch common mistakes, but they can't ensure your code does what
you intended.


Thanks guys, exactly what was needed.
--
A wise man knows he knows nothing.

Jun 9 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by achrist | last post: by
reply views Thread by Pedro Werneck | last post: by
1 post views Thread by Neal Norwitz | last post: by
10 posts views Thread by Kylotan | last post: by
12 posts views Thread by Stephen Ferg | last post: by
4 posts views Thread by beliavsky | last post: by
8 posts views Thread by Frans Englich | last post: by
21 posts views Thread by Philippe Fremy | last post: by
1 post views Thread by Neal Norwitz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.