145 if verbose:
146 sys.stderr.write("duplicate: %s (%s)\n" % potential)
147 return None
148 else:149 if not stat.S_ISREG(os.stat(potential[0]).st_mode):
150 if verbose:
151 sys.stderr.write("not a regular file: %s (%s)\n" % potential)
147 # will actually return the 2nd line in the code_context field, even though
148 # line number is itself correct. We manually fix that in this branch.
149 return fname
150 else:151 msg = (
152 "xonsh: warning: __file__ name could not be found. You may be "
153 "trying to trace interactively. Please pass in the file names "
205 for e in x:
206 if hasglobstar(e):
207 return True
208 else: 209 return False
210 else:
211 return False
67 hist_file = xt.expanduser_abs_path(hist_file)
68 if os.path.isfile(hist_file):
69 return hist_file
70 else: 71 if default:
72 default = xt.expanduser_abs_path(default)
73 if os.path.isfile(default):
When a loop specifies no break statement, the else clause will always execute when the loop sequence is empty, thus making it useless. It is recommended to have the statements under else in the same scope as the loop itself. If the else clause does not always execute at the end of a loop clause, then the code should add a break statement within the loop block.
while condition:
# body doesn't have `break` anywhere
...
else:
print("This is in the else block")
while condition:
if other_condition:
break
...
else:
print("This is in the else block")
Or, if there is no need for a break
statement in the loop, refactor it like this:
while condition:
# body doesn't have `break` anywhere
...
print("This is in the else block")