File: err_129.py

package info (click to toggle)
python-refurb 1.27.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,700 kB
  • sloc: python: 9,468; makefile: 40; sh: 6
file content (47 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# these should match

with open("file.txt") as f:
    for line in f.readlines():
        pass


with open("file.txt") as f:
    lines = [f"{line}!" for line in f.readlines()]


with open("file.txt") as f:
    lines = list(f"{line}!" for line in f.readlines())  # noqa: FURB137


with open("file.txt", "rb") as f:
    lines = list(f"{line}!" for line in f.readlines())  # noqa: FURB137


f = open("file.txt")
for line in f.readlines():
    pass


# these will not

with open("file.txt") as f:
    for line in f.readlines(1):
        pass


with open("file.txt") as f:
    for line in f:
        pass


class Reader:
    @staticmethod
    def readlines() -> list[str]:
        return ["hello", "world"]

for line in Reader.readlines():
    pass


file = open("file.txt")
x = file.readlines()