title: Why does pycharm warn about "Redeclared variable defined above without usage"?
body: <p>Why does PyCharm warn me about <code>Redeclared 'do_once' defined above without usage</code> in the below code? (warning is at line 3)</p>
  
  <pre><code>for filename in glob.glob(os.path.join(path, '*.'+filetype)):
      with open(filename, "r", encoding="utf-8") as file:
          do_once = 0
          for line in file:
              if 'this_text' in line:
                  if do_once == 0:
                      //do stuff
                      do_once = 1
                  //some other stuff because of 'this text'
              elif 'that_text' in line and do_once == 0:
                  //do stuff
                  do_once = 1
  </code></pre>
  
  <p>Since I want it to do it once for each file it seems appropriate to have it every time it opens a new file and it does work just like I want it to but since I have not studied python, just learned some stuff by doing and googling, I wanna know why it is giving me a warning and what I should do differently.</p>
  
  <p>Edit:
  Tried with a boolean instead and still got the warning:</p>
  
  <p>Short code that reproduces the warning for me:</p>
  
  <pre><code>import os
  import glob
  
  path = 'path'
  
  for filename in glob.glob(os.path.join(path, '*.txt')):
      with open(filename, "r", encoding="utf-8") as ins:
          do_once = False
          for line in ins:
              if "this" in line:
                  print("this")
              elif "something_else" in line and do_once == False:
                  do_once = True
  </code></pre>