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

undefined-loop-variable raised after for x in range(number) where x will always be defined before exiting #2533

Closed
cnjo028 opened this issue Oct 4, 2018 · 1 comment
Labels

Comments

@cnjo028
Copy link

cnjo028 commented Oct 4, 2018

Steps to reproduce

  1. Run this python script
def funkier():
    for val in range(3):
        pass
    print(val)
  1. Pylint output is
No config file found, using default configuration
************* Module test
C:  4, 0: Unnecessary parens after 'print' keyword (superfluous-parens)
C:  1, 0: Missing module docstring (missing-docstring)
C:  1, 0: Missing function docstring (missing-docstring)
W:  4,10: Using possibly undefined loop variable 'val' (undefined-loop-variable)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Current behavior

Pylint thinks that val in range( number ) may not get defined

Expected behavior

range( number ) will always pass back a value, flag shouldn't raise

pylint --version output

No config file found, using default configuration
pylint 1.9.3, 
astroid 1.6.5
Python 2.7.15 (default, May 16 2018, 17:50:09) 
[GCC 8.1.1 20180502 (Red Hat 8.1.1-1)]
@PCManticore
Copy link
Contributor

Thank you, should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants