473,666 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1935
Anthony Greene <sy******@zetaf unc.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
1963
by: achrist | last post by:
The pychecker site says that pychecker works with versions 1.5 through 2.2. Any reason to expect that 2.3 breaks it? Anyone tried it to see? TIA Al
0
1745
by: Pedro Werneck | last post by:
Hi, I don't know if I should ask this here or on an emacs group/list. If I choose wrong, please forgive me. I am trying to run pychecker on the current buffer on python-mode using the py-pychecker-run command, but it fails with the "Symbol's function definition is void: read-shell-command" error. I don't know elisp, but seems this is the point where the error occurs: ;; Pychecker (defun py-pychecker-run (command) "*Run pychecker...
1
1476
by: Neal Norwitz | last post by:
A new version of PyChecker is (finally) available for your hacking pleasure. It's been quite a while since the last release--11 months. I wish there was more progress, but such is life. Many bug fixes and some new warnings were added. I hope to get future releases out faster. I have several patches queued up and ideas for more warnings. As always, I'd like to hear your suggestions for common mistakes and bugs than can/should be...
10
3817
by: Kylotan | last post by:
Is there a practical way to use Pychecker in Windows? It doesn't work under IDLE. (In fact, it seems to end up breaking everything, and every subsequent statement and expression I execute gets ignored.) Running it from the Python interpreter in DOS means everything scrolls off the screen. Ideally I'd like to redirect it to a file, or be able to use it in IDLE. -- Ben Sizer
12
2140
by: Stephen Ferg | last post by:
I've just spent several very frustrating hours tracking down a bug in one of my programs. The problem was that I was writing text to a file, and when I was done I coded f.close when I should have been coding f.close()
4
2254
by: beliavsky | last post by:
If I run PyChecker on the following program, stored in xtry.py, m = 10000000 k = 0 for i in xrange(m): k = k + i print k x = range(3) print x
8
2082
by: Frans Englich | last post by:
Hello, I take PyChecker partly as an recommender of good coding practice, but I cannot make sense of some of the messages. For example: runner.py:878: Function (main) has too many lines (201) What does this mean? Cannot functions be large? Or is it simply an advice that functions should be small and simple?
21
1941
by: Philippe Fremy | last post by:
Hi, I would like to develop a tool that goes one step further than pychecker to ensure python program validity. The idea would be to get close to what people get on ocaml: a static verification of all types of the program, without any kind of variable declaration. This would definitely brings a lot of power to python. The idea is to analyse the whole program, identify constraints on function arguments and check that these constraints...
1
1402
by: Neal Norwitz | last post by:
Special thanks to Ken Pronovici. He did a lot of work for this release and helped ensure it occurred. Version 0.8.15 of PyChecker is available. It's been over a year since the last release. Wow, time really does fly. Since it's been so long I'm sure I screwed something up, treat it delicately. It may have bugs and erase your hard drive. If that happens, look on the bright side, you won't have any more bugs. :-) PyChecker is a...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8552
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.