From 1df896c32ca8a62739cfcdb648744c1a405d744b Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 23 Nov 2024 19:24:55 +0000 Subject: [PATCH] treewide: fix 'ruff check' errors This is mostly about unused imports. A couple errors remain, but are fine in my book (using `l` as a variable name, assigning a lambda to a variable). --- 2019/d03/ex2/ex2.py | 2 +- 2019/d05/ex1/ex1.py | 2 -- 2019/d07/ex2/ex2.py | 2 +- 2019/d09/ex1/ex1.py | 3 +-- 2019/d09/ex2/ex2.py | 3 +-- 2019/d10/ex2/ex2.py | 1 - 2019/d13/ex1/ex1.py | 2 +- 2019/d13/ex2/ex2.py | 2 +- 2019/d16/ex2/ex2.py | 2 -- 2019/d19/ex2/ex2.py | 2 +- 2020/d07/ex2/ex2.py | 2 -- 2020/d18/ex2/ex2.py | 2 +- 2020/d20/ex2/ex2.py | 1 - 2020/d23/ex1/ex1.py | 2 +- 2020/d23/ex2/ex2.py | 2 +- 2020/d24/ex2/ex2.py | 1 - 2021/d01/ex1/ex1.py | 1 - 2021/d02/ex1/ex1.py | 1 - 2021/d02/ex2/ex2.py | 1 - 2021/d03/ex1/ex1.py | 1 - 2021/d03/ex2/ex2.py | 1 - 2021/d06/ex1/ex1.py | 1 - 2021/d06/ex2/ex2.py | 1 - 2021/d07/ex1/ex1.py | 1 - 2021/d07/ex2/ex2.py | 1 - 2021/d08/ex2/ex2.py | 1 - 2021/d09/ex1/ex1.py | 1 - 2021/d09/ex2/ex2.py | 1 - 2021/d10/ex1/ex1.py | 1 - 2021/d10/ex2/ex2.py | 1 - 2021/d11/ex1/ex1.py | 1 - 2021/d11/ex2/ex2.py | 1 - 2021/d12/ex1/ex1.py | 1 - 2021/d12/ex2/ex2.py | 1 - 2021/d15/ex1/ex1.py | 3 +-- 2021/d15/ex2/ex2.py | 3 +-- 2021/d16/ex1/ex1.py | 2 +- 2021/d16/ex2/ex2.py | 2 +- 2021/d17/ex1/ex1.py | 1 - 2021/d17/ex2/ex2.py | 2 -- 2021/d18/ex2/ex2.py | 1 - 2021/d19/ex1/ex1.py | 1 - 2021/d19/ex2/ex2.py | 1 - 2021/d22/ex1/ex1.py | 2 +- 2021/d22/ex2/ex2.py | 2 +- 2021/d23/ex1/ex1.py | 2 +- 2021/d23/ex2/ex2.py | 2 +- 2021/d25/ex1/ex1.py | 3 +-- 2022/d18/ex2/ex2.py | 1 - 2022/d21/ex1/ex1.py | 2 +- 2022/d21/ex2/ex2.py | 2 +- 2023/d02/ex2/ex2.py | 2 -- 2023/d14/ex2/ex2.py | 1 - 2023/d17/ex2/ex2.py | 1 - 54 files changed, 21 insertions(+), 64 deletions(-) diff --git a/2019/d03/ex2/ex2.py b/2019/d03/ex2/ex2.py index a0abfac..077f2e3 100755 --- a/2019/d03/ex2/ex2.py +++ b/2019/d03/ex2/ex2.py @@ -2,7 +2,7 @@ import sys from fractions import Fraction -from typing import Dict, List, NamedTuple, Optional +from typing import List, NamedTuple, Optional class Point(NamedTuple): diff --git a/2019/d05/ex1/ex1.py b/2019/d05/ex1/ex1.py index 09dac02..fe46167 100755 --- a/2019/d05/ex1/ex1.py +++ b/2019/d05/ex1/ex1.py @@ -1,7 +1,5 @@ #!/usr/bin/env python -import sys -from copy import deepcopy from enum import IntEnum from typing import List, NamedTuple diff --git a/2019/d07/ex2/ex2.py b/2019/d07/ex2/ex2.py index c239eaa..8f5e209 100755 --- a/2019/d07/ex2/ex2.py +++ b/2019/d07/ex2/ex2.py @@ -5,7 +5,7 @@ import sys from copy import deepcopy from dataclasses import dataclass, field from enum import IntEnum -from typing import Callable, List, NamedTuple +from typing import List, NamedTuple class ParameterMode(IntEnum): diff --git a/2019/d09/ex1/ex1.py b/2019/d09/ex1/ex1.py index 6f54dec..9a2df1e 100755 --- a/2019/d09/ex1/ex1.py +++ b/2019/d09/ex1/ex1.py @@ -1,11 +1,10 @@ #!/usr/bin/env python -import itertools import sys from copy import deepcopy from dataclasses import dataclass, field from enum import IntEnum -from typing import Callable, List, NamedTuple +from typing import List, NamedTuple class ParameterMode(IntEnum): diff --git a/2019/d09/ex2/ex2.py b/2019/d09/ex2/ex2.py index 598f628..7c8be67 100755 --- a/2019/d09/ex2/ex2.py +++ b/2019/d09/ex2/ex2.py @@ -1,11 +1,10 @@ #!/usr/bin/env python -import itertools import sys from copy import deepcopy from dataclasses import dataclass, field from enum import IntEnum -from typing import Callable, List, NamedTuple +from typing import List, NamedTuple class ParameterMode(IntEnum): diff --git a/2019/d10/ex2/ex2.py b/2019/d10/ex2/ex2.py index 60f115a..480234e 100755 --- a/2019/d10/ex2/ex2.py +++ b/2019/d10/ex2/ex2.py @@ -4,7 +4,6 @@ import sys from cmath import phase from itertools import groupby from math import gcd, pi -from pprint import pprint from typing import NamedTuple, Set, Tuple diff --git a/2019/d13/ex1/ex1.py b/2019/d13/ex1/ex1.py index 1bf7e8c..924ffb7 100755 --- a/2019/d13/ex1/ex1.py +++ b/2019/d13/ex1/ex1.py @@ -3,7 +3,7 @@ import sys from dataclasses import dataclass, field from enum import IntEnum -from typing import Dict, Iterable, List, NamedTuple, Tuple, TypeVar +from typing import Iterable, List, NamedTuple, Tuple, TypeVar class ParameterMode(IntEnum): diff --git a/2019/d13/ex2/ex2.py b/2019/d13/ex2/ex2.py index 9fb669f..af0d24f 100755 --- a/2019/d13/ex2/ex2.py +++ b/2019/d13/ex2/ex2.py @@ -3,7 +3,7 @@ import sys from dataclasses import dataclass, field from enum import IntEnum -from typing import Dict, Iterable, List, NamedTuple, Tuple, TypeVar +from typing import Iterable, List, NamedTuple, Tuple, TypeVar class ParameterMode(IntEnum): diff --git a/2019/d16/ex2/ex2.py b/2019/d16/ex2/ex2.py index a13a0bf..317d157 100755 --- a/2019/d16/ex2/ex2.py +++ b/2019/d16/ex2/ex2.py @@ -2,8 +2,6 @@ import sys from functools import reduce -from itertools import chain, cycle -from typing import Iterable, List def main() -> None: diff --git a/2019/d19/ex2/ex2.py b/2019/d19/ex2/ex2.py index 138e45b..8dd132c 100755 --- a/2019/d19/ex2/ex2.py +++ b/2019/d19/ex2/ex2.py @@ -4,7 +4,7 @@ import sys from copy import deepcopy from dataclasses import dataclass, field from enum import IntEnum -from typing import Iterator, List, NamedTuple, Tuple +from typing import List, NamedTuple class ParameterMode(IntEnum): diff --git a/2020/d07/ex2/ex2.py b/2020/d07/ex2/ex2.py index 107d737..a955087 100755 --- a/2020/d07/ex2/ex2.py +++ b/2020/d07/ex2/ex2.py @@ -2,8 +2,6 @@ import re import sys -from collections import defaultdict -from copy import deepcopy from dataclasses import dataclass from typing import Dict, List, Set, Tuple diff --git a/2020/d18/ex2/ex2.py b/2020/d18/ex2/ex2.py index 94f13ed..a83161c 100755 --- a/2020/d18/ex2/ex2.py +++ b/2020/d18/ex2/ex2.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import sys -from typing import Callable, Dict, List +from typing import List """ E : T [ * T ]* diff --git a/2020/d20/ex2/ex2.py b/2020/d20/ex2/ex2.py index e923806..c9e06a7 100755 --- a/2020/d20/ex2/ex2.py +++ b/2020/d20/ex2/ex2.py @@ -5,7 +5,6 @@ import itertools import math import sys from collections import defaultdict -from copy import deepcopy from typing import Dict, Iterator, List, Set, Tuple Tile = List[List[str]] diff --git a/2020/d23/ex1/ex1.py b/2020/d23/ex1/ex1.py index faae133..2d7ff20 100755 --- a/2020/d23/ex1/ex1.py +++ b/2020/d23/ex1/ex1.py @@ -2,7 +2,7 @@ import itertools import sys -from typing import List, Tuple +from typing import List def solve(circle: List[int]) -> int: diff --git a/2020/d23/ex2/ex2.py b/2020/d23/ex2/ex2.py index 90c8c81..8993dcb 100755 --- a/2020/d23/ex2/ex2.py +++ b/2020/d23/ex2/ex2.py @@ -2,7 +2,7 @@ import itertools import sys -from typing import List, Tuple +from typing import List def solve(circle: List[int]) -> int: diff --git a/2020/d24/ex2/ex2.py b/2020/d24/ex2/ex2.py index 17728b2..ef749f9 100755 --- a/2020/d24/ex2/ex2.py +++ b/2020/d24/ex2/ex2.py @@ -3,7 +3,6 @@ import itertools import sys from collections import defaultdict -from copy import deepcopy from typing import Dict, Iterator, List, Tuple Offset = Tuple[int, int] diff --git a/2021/d01/ex1/ex1.py b/2021/d01/ex1/ex1.py index 24cc5d1..3853ce4 100755 --- a/2021/d01/ex1/ex1.py +++ b/2021/d01/ex1/ex1.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from typing import List diff --git a/2021/d02/ex1/ex1.py b/2021/d02/ex1/ex1.py index f28dd77..f891b43 100755 --- a/2021/d02/ex1/ex1.py +++ b/2021/d02/ex1/ex1.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from typing import List diff --git a/2021/d02/ex2/ex2.py b/2021/d02/ex2/ex2.py index b48215c..8843639 100755 --- a/2021/d02/ex2/ex2.py +++ b/2021/d02/ex2/ex2.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from typing import List diff --git a/2021/d03/ex1/ex1.py b/2021/d03/ex1/ex1.py index ed2eeb7..7519004 100755 --- a/2021/d03/ex1/ex1.py +++ b/2021/d03/ex1/ex1.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from typing import List diff --git a/2021/d03/ex2/ex2.py b/2021/d03/ex2/ex2.py index 9c6515b..acf0ff2 100755 --- a/2021/d03/ex2/ex2.py +++ b/2021/d03/ex2/ex2.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from copy import deepcopy from typing import List diff --git a/2021/d06/ex1/ex1.py b/2021/d06/ex1/ex1.py index 5eec9ce..65abb44 100755 --- a/2021/d06/ex1/ex1.py +++ b/2021/d06/ex1/ex1.py @@ -3,7 +3,6 @@ import itertools import sys from collections import Counter -from dataclasses import dataclass from typing import Iterator, List, TypeVar T = TypeVar("T") diff --git a/2021/d06/ex2/ex2.py b/2021/d06/ex2/ex2.py index 2e64423..bb40805 100755 --- a/2021/d06/ex2/ex2.py +++ b/2021/d06/ex2/ex2.py @@ -3,7 +3,6 @@ import itertools import sys from collections import Counter -from dataclasses import dataclass from typing import Iterator, List, TypeVar T = TypeVar("T") diff --git a/2021/d07/ex1/ex1.py b/2021/d07/ex1/ex1.py index 4205009..2b8a8a9 100755 --- a/2021/d07/ex1/ex1.py +++ b/2021/d07/ex1/ex1.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from typing import List diff --git a/2021/d07/ex2/ex2.py b/2021/d07/ex2/ex2.py index 56b818c..8eec5ef 100755 --- a/2021/d07/ex2/ex2.py +++ b/2021/d07/ex2/ex2.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from math import ceil, floor from typing import List diff --git a/2021/d08/ex2/ex2.py b/2021/d08/ex2/ex2.py index 1553e29..c22b23b 100755 --- a/2021/d08/ex2/ex2.py +++ b/2021/d08/ex2/ex2.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from dataclasses import dataclass from typing import Dict, List, Set diff --git a/2021/d09/ex1/ex1.py b/2021/d09/ex1/ex1.py index cf7d7d6..e84e893 100755 --- a/2021/d09/ex1/ex1.py +++ b/2021/d09/ex1/ex1.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from typing import Iterator, List, Tuple diff --git a/2021/d09/ex2/ex2.py b/2021/d09/ex2/ex2.py index 451883a..0311995 100755 --- a/2021/d09/ex2/ex2.py +++ b/2021/d09/ex2/ex2.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from typing import Iterator, List, Tuple diff --git a/2021/d10/ex1/ex1.py b/2021/d10/ex1/ex1.py index 4667d43..6770222 100755 --- a/2021/d10/ex1/ex1.py +++ b/2021/d10/ex1/ex1.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from typing import List, Optional, cast diff --git a/2021/d10/ex2/ex2.py b/2021/d10/ex2/ex2.py index 27de8ac..d100b0f 100755 --- a/2021/d10/ex2/ex2.py +++ b/2021/d10/ex2/ex2.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from typing import Iterator, List, Optional diff --git a/2021/d11/ex1/ex1.py b/2021/d11/ex1/ex1.py index 619bd27..c6bf0be 100755 --- a/2021/d11/ex1/ex1.py +++ b/2021/d11/ex1/ex1.py @@ -2,7 +2,6 @@ import itertools import sys -from copy import deepcopy from typing import Iterator, List, Set, Tuple Grid = List[List[int]] diff --git a/2021/d11/ex2/ex2.py b/2021/d11/ex2/ex2.py index d4ce118..8f95f55 100755 --- a/2021/d11/ex2/ex2.py +++ b/2021/d11/ex2/ex2.py @@ -2,7 +2,6 @@ import itertools import sys -from copy import deepcopy from typing import Iterator, List, Set, Tuple Grid = List[List[int]] diff --git a/2021/d12/ex1/ex1.py b/2021/d12/ex1/ex1.py index 1887c7d..6108876 100755 --- a/2021/d12/ex1/ex1.py +++ b/2021/d12/ex1/ex1.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from collections import defaultdict from typing import Dict, List, Set diff --git a/2021/d12/ex2/ex2.py b/2021/d12/ex2/ex2.py index bc5a527..b30d9b8 100755 --- a/2021/d12/ex2/ex2.py +++ b/2021/d12/ex2/ex2.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import itertools import sys from collections import defaultdict from typing import Dict, List, Set diff --git a/2021/d15/ex1/ex1.py b/2021/d15/ex1/ex1.py index d7c5e88..4399aba 100755 --- a/2021/d15/ex1/ex1.py +++ b/2021/d15/ex1/ex1.py @@ -1,9 +1,8 @@ #!/usr/bin/env python import heapq -import itertools import sys -from typing import Iterator, List, NamedTuple, Set, Tuple +from typing import Iterator, List, NamedTuple, Set class Point(NamedTuple): diff --git a/2021/d15/ex2/ex2.py b/2021/d15/ex2/ex2.py index 0fa89b8..c2bbd30 100755 --- a/2021/d15/ex2/ex2.py +++ b/2021/d15/ex2/ex2.py @@ -1,9 +1,8 @@ #!/usr/bin/env python import heapq -import itertools import sys -from typing import Iterator, List, NamedTuple, Set, Tuple +from typing import Iterator, List, NamedTuple, Set class Point(NamedTuple): diff --git a/2021/d16/ex1/ex1.py b/2021/d16/ex1/ex1.py index d65fec5..1978196 100755 --- a/2021/d16/ex1/ex1.py +++ b/2021/d16/ex1/ex1.py @@ -5,7 +5,7 @@ import functools import itertools import sys from dataclasses import dataclass -from typing import Iterable, Iterator, List, Tuple, TypeVar +from typing import Iterable, Iterator, List, Tuple RawPacket = List[bool] diff --git a/2021/d16/ex2/ex2.py b/2021/d16/ex2/ex2.py index 7ecb73a..bb9ad4e 100755 --- a/2021/d16/ex2/ex2.py +++ b/2021/d16/ex2/ex2.py @@ -6,7 +6,7 @@ import itertools import math import sys from dataclasses import dataclass -from typing import Callable, Dict, Iterable, Iterator, List, Tuple, TypeVar +from typing import Callable, Dict, Iterable, Iterator, List, Tuple RawPacket = List[bool] diff --git a/2021/d17/ex1/ex1.py b/2021/d17/ex1/ex1.py index d58a72e..00bbca2 100755 --- a/2021/d17/ex1/ex1.py +++ b/2021/d17/ex1/ex1.py @@ -1,7 +1,6 @@ #!/usr/bin/env python import itertools -import math import sys from typing import Iterator, List, NamedTuple diff --git a/2021/d17/ex2/ex2.py b/2021/d17/ex2/ex2.py index e2beb9a..bc7dab1 100755 --- a/2021/d17/ex2/ex2.py +++ b/2021/d17/ex2/ex2.py @@ -1,7 +1,5 @@ #!/usr/bin/env python -import itertools -import math import sys from typing import Iterator, List, NamedTuple diff --git a/2021/d18/ex2/ex2.py b/2021/d18/ex2/ex2.py index 56c8d48..c0a37a7 100755 --- a/2021/d18/ex2/ex2.py +++ b/2021/d18/ex2/ex2.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import functools import itertools import sys from copy import deepcopy diff --git a/2021/d19/ex1/ex1.py b/2021/d19/ex1/ex1.py index 922e709..e42af3c 100755 --- a/2021/d19/ex1/ex1.py +++ b/2021/d19/ex1/ex1.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import functools import itertools import sys from dataclasses import dataclass diff --git a/2021/d19/ex2/ex2.py b/2021/d19/ex2/ex2.py index 1ad850a..ff4f6ad 100755 --- a/2021/d19/ex2/ex2.py +++ b/2021/d19/ex2/ex2.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import functools import itertools import sys from dataclasses import dataclass diff --git a/2021/d22/ex1/ex1.py b/2021/d22/ex1/ex1.py index 662dd49..dac1513 100755 --- a/2021/d22/ex1/ex1.py +++ b/2021/d22/ex1/ex1.py @@ -3,7 +3,7 @@ import functools import itertools import sys -from typing import Iterator, List, NamedTuple, Optional, Set, Tuple, cast +from typing import List, NamedTuple, Optional, Set, Tuple class Point(NamedTuple): diff --git a/2021/d22/ex2/ex2.py b/2021/d22/ex2/ex2.py index 4753b54..3c7d2c5 100755 --- a/2021/d22/ex2/ex2.py +++ b/2021/d22/ex2/ex2.py @@ -3,7 +3,7 @@ import functools import itertools import sys -from typing import Iterator, List, NamedTuple, Optional, Set, Tuple, cast +from typing import List, NamedTuple, Optional, Set, Tuple class Point(NamedTuple): diff --git a/2021/d23/ex1/ex1.py b/2021/d23/ex1/ex1.py index 4d585cd..0b99d71 100755 --- a/2021/d23/ex1/ex1.py +++ b/2021/d23/ex1/ex1.py @@ -3,7 +3,7 @@ import enum import functools import sys -from typing import Iterator, List, NamedTuple, Optional, Tuple, cast +from typing import Iterator, List, NamedTuple, Optional, Tuple class Point(NamedTuple): diff --git a/2021/d23/ex2/ex2.py b/2021/d23/ex2/ex2.py index 1ea1d8f..8c077d9 100755 --- a/2021/d23/ex2/ex2.py +++ b/2021/d23/ex2/ex2.py @@ -3,7 +3,7 @@ import enum import functools import sys -from typing import Iterator, List, NamedTuple, Optional, Tuple, cast +from typing import Iterator, List, NamedTuple, Optional, Tuple class Point(NamedTuple): diff --git a/2021/d25/ex1/ex1.py b/2021/d25/ex1/ex1.py index fe8132c..5d6f612 100755 --- a/2021/d25/ex1/ex1.py +++ b/2021/d25/ex1/ex1.py @@ -1,9 +1,8 @@ #!/usr/bin/env python -import enum import itertools import sys -from typing import Iterable, Iterator, List, NamedTuple, Set +from typing import List, NamedTuple, Set class Point(NamedTuple): diff --git a/2022/d18/ex2/ex2.py b/2022/d18/ex2/ex2.py index 6f7bfcb..57f8b5a 100755 --- a/2022/d18/ex2/ex2.py +++ b/2022/d18/ex2/ex2.py @@ -2,7 +2,6 @@ import itertools import sys -from collections import deque from collections.abc import Iterator from typing import NamedTuple diff --git a/2022/d21/ex1/ex1.py b/2022/d21/ex1/ex1.py index 7c12836..e9c4727 100755 --- a/2022/d21/ex1/ex1.py +++ b/2022/d21/ex1/ex1.py @@ -25,7 +25,7 @@ class Operator(str, enum.Enum): class Monkey: def get_value(self, monkeys: dict[str, "Monkey"]) -> int: - raise NotImplemented + raise NotImplementedError @dataclasses.dataclass diff --git a/2022/d21/ex2/ex2.py b/2022/d21/ex2/ex2.py index ec9ca8d..386a187 100755 --- a/2022/d21/ex2/ex2.py +++ b/2022/d21/ex2/ex2.py @@ -93,7 +93,7 @@ class MathObserver: class Monkey: def get_value(self, monkeys: dict[str, "Monkey"]) -> Num: - raise NotImplemented + raise NotImplementedError @dataclasses.dataclass diff --git a/2023/d02/ex2/ex2.py b/2023/d02/ex2/ex2.py index 309753e..32c3a34 100755 --- a/2023/d02/ex2/ex2.py +++ b/2023/d02/ex2/ex2.py @@ -1,8 +1,6 @@ #!/usr/bin/env python -import functools import math -import operator as op import sys from collections import Counter from enum import StrEnum diff --git a/2023/d14/ex2/ex2.py b/2023/d14/ex2/ex2.py index 090724f..b7b0222 100755 --- a/2023/d14/ex2/ex2.py +++ b/2023/d14/ex2/ex2.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import dataclasses import itertools import sys from enum import StrEnum diff --git a/2023/d17/ex2/ex2.py b/2023/d17/ex2/ex2.py index a643534..f4cfc6e 100755 --- a/2023/d17/ex2/ex2.py +++ b/2023/d17/ex2/ex2.py @@ -2,7 +2,6 @@ import functools import heapq -import itertools import sys from collections.abc import Iterator from enum import Enum