]>
git.proxmox.com Git - ceph.git/blob - ceph/src/script/run_mypy.sh
3 # needs to be executed from the src directory.
4 # generates a report at src/mypy_report.txt
8 python3
-m venv .mypy_venv
10 . .mypy_venv
/bin
/activate
12 ! pip
install $
(find -name requirements.txt
-not -path './frontend/*' -printf '-r%p ')
15 MYPY_INI
="$PWD"/mypy.ini
17 export MYPYPATH
="$PWD/pybind/rados:$PWD/pybind/rbd:$PWD/pybind/cephfs"
19 echo -n > mypy_report.txt
21 mypy
--config-file="$MYPY_INI" *.py |
awk '{print "pybind/" $0}' >> ..
/mypy_report.txt
25 mypy
--config-file="$MYPY_INI" $
(find * -name '*.py' |
grep -v -e venv
-e tox
-e env
-e gyp
-e node_modules
) |
awk '{print "pybind/mgr/" $0}' >> ..
/..
/mypy_report.txt
28 pushd ceph-volume
/ceph_volume
29 mypy
--config-file="$MYPY_INI" $
(find * -name '*.py' |
grep -v -e venv
-e tox
-e env
-e gyp
-e node_modules
-e tests
) |
awk '{print "ceph-volume/ceph_volume/" $0}' >> ..
/..
/mypy_report.txt
32 SORT_MYPY
=$
(cat <<-EOF
35 from collections import namedtuple
37 class Line(namedtuple('Line', 'prefix no rest')):
42 if re.search('Found [0-9]+ errors in [0-9]+ files', l):
44 p, *rest = l.split(':', 2)
46 return cls(p, 0, rest[0])
49 return cls(p, int(rest[0]), rest[1])
51 return cls(p, 0, rest[0] + ':' + rest[1])
55 def __init__(self, line):
59 def matches(self, other):
60 return Line.parse(self.line).prefix == Line.parse(other).prefix
63 return bool(self.lines) or ': note: In' not in self.line
66 return '\n'.join([self.line] + self.lines)
69 l1 = Line.parse(self.line)
71 return l1.prefix, int(l1.no)
73 return l1.prefix, None
74 return l1.prefix, Line.parse(self.lines[0]).no
83 groups.append(Group(''))
88 if ': note: In' in l or not group().matches(l):
89 groups.append(Group(l))
93 group().lines.append(l)
95 return (g for g in groups if g)
98 groups = sorted(groups, key=Group.key)
99 return '\n'.join(map(str, groups))
101 with open('mypy_report.txt') as f:
102 new = render(parse(f))
103 with open('mypy_report.txt', 'w') as f:
108 python
<(echo "$SORT_MYPY")