This is a deficiency, but it should be addressed in our next release, since I've just finished rewriting a large part of how we analyse code. At the moment, we know that readlines() returns a list, but we don't know what is in that list.
The easiest way to force a certain type is to assign it:
in_file = open("foo.txt", "r")
line = ""
for line in in_file.readlines():
line.
The extra assignment could be if False: line = "" if you don't want to actually execute it.
We also handle the following pattern:
in_file = open("foo.txt", "r")
for line in in_file.readlines():
assert isinstance(line, str)
line.
This has the added benefit of removing any other types from line. It's not always reliable in the current version, but I've fixed it for the next. (We'll have a preview release soon, which is when this sort of feedback is going to be really important to us.)
|