Issue 25964: optparse.py:1668: (file) shadows builtin (original) (raw)

Issue25964

Created on 2015-12-28 10:09 by mmokrejs, last changed 2022-04-11 14:58 by admin. 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
2022-04-11 14:58:25 admin set github: 70152
2015-12-28 10:24:40 SilentGhost set messages: +
2015-12-28 10:20:03 mmokrejs set messages: +
2015-12-28 10:16:14 SilentGhost set status: open -> closedtype: enhancement -> behaviorcomponents: + Library (Lib)nosy: + SilentGhostmessages: + resolution: not a bugstage: resolved
2015-12-28 10:09:18 mmokrejs create