diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index f37e711..f6d9ed6 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -34,7 +34,7 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Type check with mypy run: | - mypy . --exclude example/ + mypy . - name: Test with pytest run: | pytest diff --git a/atcoder/mincostflow.py b/atcoder/mincostflow.py index 4908b89..db76cdc 100644 --- a/atcoder/mincostflow.py +++ b/atcoder/mincostflow.py @@ -51,10 +51,12 @@ def get_edge(self, i: int) -> Edge: def edges(self) -> List[Edge]: return [self.get_edge(i) for i in range(len(self._edges))] - def flow(self, s: int, t: int, flow_limit: Optional[int] = None) -> Tuple[int, int]: + def flow(self, s: int, t: int, + flow_limit: Optional[int] = None) -> Tuple[int, int]: return self.slope(s, t, flow_limit)[-1] - def slope(self, s: int, t: int, flow_limit: Optional[int] = None) -> List[Tuple[int, int]]: + def slope(self, s: int, t: int, + flow_limit: Optional[int] = None) -> List[Tuple[int, int]]: assert 0 <= s < self._n assert 0 <= t < self._n assert s != t diff --git a/example/__init__.py b/example/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/example/lazysegtree_practice_k.py b/example/lazysegtree_practice_k.py index 34fc55c..dcc1e16 100644 --- a/example/lazysegtree_practice_k.py +++ b/example/lazysegtree_practice_k.py @@ -1,6 +1,7 @@ # https://atcoder.jp/contests/practice2/tasks/practice2_k import sys +from typing import Tuple from atcoder.lazysegtree import LazySegTree from atcoder.modint import ModContext, Modint @@ -11,16 +12,18 @@ def main() -> None: n, q = map(int, sys.stdin.readline().split()) a = [(Modint(ai), 1) for ai in map(int, sys.stdin.readline().split())] - def op(x: (Modint, int), y: (Modint, int)) -> (Modint, int): + def op(x: Tuple[Modint, int], + y: Tuple[Modint, int]) -> Tuple[Modint, int]: return x[0] + y[0], x[1] + y[1] e = Modint(0), 0 - def mapping(x: (Modint, Modint), y: (Modint, int)) -> (Modint, int): + def mapping(x: Tuple[Modint, Modint], + y: Tuple[Modint, int]) -> Tuple[Modint, int]: return x[0] * y[0] + x[1] * y[1], y[1] - def composition(x: (Modint, Modint), - y: (Modint, Modint)) -> (Modint, Modint): + def composition(x: Tuple[Modint, Modint], + y: Tuple[Modint, Modint]) -> Tuple[Modint, Modint]: return x[0] * y[0], x[0] * y[1] + x[1] id_ = Modint(1), Modint(0) diff --git a/example/lazysegtree_practice_k_wo_modint.py b/example/lazysegtree_practice_k_wo_modint.py index bc75e8c..fabdc8e 100644 --- a/example/lazysegtree_practice_k_wo_modint.py +++ b/example/lazysegtree_practice_k_wo_modint.py @@ -1,6 +1,7 @@ # https://atcoder.jp/contests/practice2/tasks/practice2_k import sys +from typing import Tuple from atcoder.lazysegtree import LazySegTree @@ -11,15 +12,15 @@ def main() -> None: n, q = map(int, sys.stdin.readline().split()) a = [(ai, 1) for ai in map(int, sys.stdin.readline().split())] - def op(x: (int, int), y: (int, int)) -> (int, int): + def op(x: Tuple[int, int], y: Tuple[int, int]) -> Tuple[int, int]: return (x[0] + y[0]) % mod, x[1] + y[1] e = 0, 0 - def mapping(x: (int, int), y: (int, int)) -> (int, int): + def mapping(x: Tuple[int, int], y: Tuple[int, int]) -> Tuple[int, int]: return (x[0] * y[0] + x[1] * y[1]) % mod, y[1] - def composition(x: (int, int), y: (int, int)) -> (int, int): + def composition(x: Tuple[int, int], y: Tuple[int, int]) -> Tuple[int, int]: return (x[0] * y[0]) % mod, (x[0] * y[1] + x[1]) % mod id_ = 1, 0 diff --git a/example/lazysegtree_practice_l.py b/example/lazysegtree_practice_l.py index 6c17418..23e2e66 100644 --- a/example/lazysegtree_practice_l.py +++ b/example/lazysegtree_practice_l.py @@ -1,6 +1,7 @@ # https://atcoder.jp/contests/practice2/tasks/practice2_l import sys +from typing import Tuple from atcoder.lazysegtree import LazySegTree @@ -14,12 +15,13 @@ def main() -> None: else: a.append((0, 1, 0)) - def op(x: (int, int, int), y: (int, int, int)) -> (int, int, int): + def op(x: Tuple[int, int, int], + y: Tuple[int, int, int]) -> Tuple[int, int, int]: return x[0] + y[0], x[1] + y[1], x[2] + y[2] + x[1] * y[0] e = (0, 0, 0) - def mapping(x: bool, y: (int, int, int)) -> (int, int, int): + def mapping(x: bool, y: Tuple[int, int, int]) -> Tuple[int, int, int]: if not x: return y return y[1], y[0], y[0] * y[1] - y[2] diff --git a/example/maxflow_practice.py b/example/maxflow_practice.py index 6112340..08bb8c9 100644 --- a/example/maxflow_practice.py +++ b/example/maxflow_practice.py @@ -1,6 +1,7 @@ # https://atcoder.jp/contests/practice2/tasks/practice2_d import sys +from typing import Tuple from atcoder.maxflow import MFGraph @@ -15,7 +16,7 @@ def main() -> None: def enc(i: int, j: int) -> int: return i * m + j - def dec(v: int) -> (int, int): + def dec(v: int) -> Tuple[int, int]: return v // m, v % m for i in range(n): @@ -58,8 +59,8 @@ def dec(v: int) -> (int, int): grid[i][j] = '>' grid[ii][jj] = '<' - for s in grid: - print("".join(s)) + for r in grid: + print("".join(r)) if __name__ == '__main__': diff --git a/example/mincostflow_practice.py b/example/mincostflow_practice.py index 144767d..065d553 100644 --- a/example/mincostflow_practice.py +++ b/example/mincostflow_practice.py @@ -1,6 +1,7 @@ # https://atcoder.jp/contests/practice2/tasks/practice2_e import sys +from typing import List from atcoder.mincostflow import MCFGraph @@ -12,7 +13,7 @@ def main() -> None: g = MCFGraph(t + 1) grid = [list(map(int, sys.stdin.readline().split())) for _ in range(n)] big = 10 ** 9 - edges = list([] for _ in range(n)) + edges: List[List[int]] = list([] for _ in range(n)) for i in range(n): g.add_edge(s, i, k, 0) g.add_edge(i + n, t, k, 0) @@ -29,8 +30,8 @@ def main() -> None: if g.get_edge(edges[i][j]).flow > 0: result[i][j] = 'X' - for s in result: - print("".join(s)) + for r in result: + print("".join(r)) if __name__ == '__main__': diff --git a/example/scc_practice.py b/example/scc_practice.py index e4bb266..8d2811b 100644 --- a/example/scc_practice.py +++ b/example/scc_practice.py @@ -16,9 +16,9 @@ def main() -> None: scc = g.scc() print(len(scc)) - for v in scc: - print(len(v), end='') - for x in v: + for c in scc: + print(len(c), end='') + for x in c: print(f' {x}', end='') print('')