classification
Title: optparse.py:1668: (file) shadows builtin
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: SilentGhost, mmokrejs
Priority: normal Keywords:

Created on 2015-12-28 10:09 by mmokrejs, last changed 2015-12-28 10:24 by SilentGhost. This issue is now closed.

Messages (4)
msg257110 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2015-12-28 10:09
I use pychecker for checking my python code. Seems optparse.py distributed with python-2.7 could be improved as well:

[system path]/optparse.py:1191: Function (__init__) has too many arguments (11)
[system path]/optparse.py:1206: Local variable (version) shadows global defined on line 10 in file my-test-code.py
[system path]/optparse.py:1400: Local variable (stop) not used
[system path]/optparse.py:1668: (file) shadows builtin


Interestingly, my version variable is overridden by one from optparse.py. But more worrisome is the 'file' variable name.
msg257112 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2015-12-28 10:16
None of this warnings highlights a real issue. Furthermore, optparse module is deprecated and you'd be better off using argparse instead.
msg257113 - (view) Author: Martin Mokrejs (mmokrejs) Date: 2015-12-28 10:20
But couldn't somebody just rename the variable for example to _file? I see optparse also in python-3.5 so I did not think it could be Deprecated.
msg257114 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2015-12-28 10:24
The deprecation warning is clearly displayed at the top of the module documentation: https://docs.python.org/3/library/optparse.html 

Regarding variable names: it is not an issue and pychecker is simply mistaken here.
History
Date User Action Args
2015-12-28 10:24:40SilentGhostsetmessages: + msg257114
2015-12-28 10:20:03mmokrejssetmessages: + msg257113
2015-12-28 10:16:14SilentGhostsetstatus: open -> closed

type: enhancement -> behavior
components: + Library (Lib)

nosy: + SilentGhost
messages: + msg257112
resolution: not a bug
stage: resolved
2015-12-28 10:09:18mmokrejscreate