Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optparse.py:1668: (file) shadows builtin #70152

Closed
mmokrejs mannequin opened this issue Dec 28, 2015 · 4 comments
Closed

optparse.py:1668: (file) shadows builtin #70152

mmokrejs mannequin opened this issue Dec 28, 2015 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@mmokrejs
Copy link
Mannequin

mmokrejs mannequin commented Dec 28, 2015

BPO 25964

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2015-12-28.10:16:14.522>
created_at = <Date 2015-12-28.10:09:18.072>
labels = ['invalid', 'type-bug', 'library']
title = 'optparse.py:1668: (file) shadows builtin'
updated_at = <Date 2015-12-28.10:24:40.971>
user = 'https://bugs.python.org/mmokrejs'

bugs.python.org fields:

activity = <Date 2015-12-28.10:24:40.971>
actor = 'SilentGhost'
assignee = 'none'
closed = True
closed_date = <Date 2015-12-28.10:16:14.522>
closer = 'SilentGhost'
components = ['Library (Lib)']
creation = <Date 2015-12-28.10:09:18.072>
creator = 'mmokrejs'
dependencies = []
files = []
hgrepos = []
issue_num = 25964
keywords = []
message_count = 4.0
messages = ['257110', '257112', '257113', '257114']
nosy_count = 2.0
nosy_names = ['mmokrejs', 'SilentGhost']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue25964'
versions = ['Python 2.7']

@mmokrejs
Copy link
Mannequin Author

mmokrejs mannequin commented Dec 28, 2015

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.

@mmokrejs mmokrejs mannequin added the type-feature A feature request or enhancement label Dec 28, 2015
@SilentGhost
Copy link
Mannequin

SilentGhost mannequin commented Dec 28, 2015

None of this warnings highlights a real issue. Furthermore, optparse module is deprecated and you'd be better off using argparse instead.

@SilentGhost SilentGhost mannequin added the stdlib Python modules in the Lib dir label Dec 28, 2015
@SilentGhost SilentGhost mannequin closed this as completed Dec 28, 2015
@SilentGhost SilentGhost mannequin added invalid type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Dec 28, 2015
@mmokrejs
Copy link
Mannequin Author

mmokrejs mannequin commented Dec 28, 2015

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.

@SilentGhost
Copy link
Mannequin

SilentGhost mannequin commented Dec 28, 2015

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

0 participants