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

false redefined-outer-name when using del #841

Open
vapier opened this issue Mar 8, 2016 · 6 comments
Open

false redefined-outer-name when using del #841

vapier opened this issue Mar 8, 2016 · 6 comments
Labels
Control flow Requires control flow understanding False Positive 🦟 A message is emitted but nothing is wrong with the code Minor 💅 Polishing pylint is always nice Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@vapier
Copy link
Contributor

vapier commented Mar 8, 2016

simple test code:

path = __file__
del path
def some_func_of_mine(path):
    print(path)

testing pylint-1.5.4 shows:

$ pylint test.py
W:  3,22: Redefining name 'path' from outer scope (line 1) (redefined-outer-name)
@PCManticore
Copy link
Contributor

We don't understand deletions of values yet.

@PCManticore PCManticore added the Minor 💅 Polishing pylint is always nice label Mar 21, 2016
@dumblob
Copy link

dumblob commented Jul 23, 2020

This would be great addition. It's one of the most frequent errors we always get.

I didn't look at the internals, but would it make sense to look at how mypy solves this (mypy understands del statements and does not produce any false positivess)?

@Pierre-Sassoulas Pierre-Sassoulas added Control flow Requires control flow understanding False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Bug 🪲 labels Jun 30, 2022
@clavedeluna
Copy link
Collaborator

I'm looking at how to approach this. this is the code near where "redefined-outer-name" is about to be emitted.

In the orig example in this issue

path = __file__
del path
def some_func_of_mine(path):
    print(path)

globs is

(Pdb) globs
{'path': [<AssignName.path l.1 at 0x10ad69f40>, <DelName.path l.2 at 0x10ade0070>], 'some_func_of_mine': [<FunctionDef.some_func_of_mine l.3 at 0x10ade0040>]}

Seems like we could use this information, particularly the fact that DelName.path exists, and short-circuit so that Redefining name 'path' from outer scope (line 1) (redefined-outer-name) isn't part of the output.

Thoughts?

@Pierre-Sassoulas
Copy link
Member

This seems dependent on #4795, doing it in each possible checker will be very hard to maintain and do right.

@clavedeluna
Copy link
Collaborator

This seems dependent on #4795, doing it in each possible checker will be very hard to maintain and do right.

Sounds good. Then the minor label isn't applicable, correct?

@Pierre-Sassoulas
Copy link
Member

minor means "polishing" i.e. low priority, not "easy to do " :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Control flow Requires control flow understanding False Positive 🦟 A message is emitted but nothing is wrong with the code Minor 💅 Polishing pylint is always nice Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

5 participants