Skip to content

Upgrade to flake8 v6 #8007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ max-line-length = 88
max-complexity = 19
extend-ignore =
# Formatting style for `black`
E203 # Whitespace before ':'
W503 # Line break occurred before a binary operator
# E203 is whitespace before ':'
E203,
# W503 is line break occurred before a binary operator
W503
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-executables-have-shebangs
- id: check-yaml
Expand Down Expand Up @@ -34,13 +34,13 @@ repos:
- --py311-plus

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8 # See .flake8 for args
additional_dependencies: &flake8-plugins
- flake8-bugbear
- flake8-builtins
- flake8-broken-line
# - flake8-broken-line
- flake8-comprehensions
- pep8-naming

Expand Down
2 changes: 2 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@
* [Articulation Points](graphs/articulation_points.py)
* [Basic Graphs](graphs/basic_graphs.py)
* [Bellman Ford](graphs/bellman_ford.py)
* [Bi Directional Dijkstra](graphs/bi_directional_dijkstra.py)
* [Bidirectional A Star](graphs/bidirectional_a_star.py)
* [Bidirectional Breadth First Search](graphs/bidirectional_breadth_first_search.py)
* [Boruvka](graphs/boruvka.py)
Expand Down Expand Up @@ -563,6 +564,7 @@
* [Is Ip V4 Address Valid](maths/is_ip_v4_address_valid.py)
* [Is Square Free](maths/is_square_free.py)
* [Jaccard Similarity](maths/jaccard_similarity.py)
* [Juggler Sequence](maths/juggler_sequence.py)
* [Kadanes](maths/kadanes.py)
* [Karatsuba](maths/karatsuba.py)
* [Krishnamurthy Number](maths/krishnamurthy_number.py)
Expand Down
4 changes: 2 additions & 2 deletions compression/huffman.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def parse_file(file_path: str) -> list[Letter]:
if not c:
break
chars[c] = chars[c] + 1 if c in chars else 1
return sorted((Letter(c, f) for c, f in chars.items()), key=lambda l: l.freq)
return sorted((Letter(c, f) for c, f in chars.items()), key=lambda x: x.freq)


def build_tree(letters: list[Letter]) -> Letter | TreeNode:
Expand All @@ -47,7 +47,7 @@ def build_tree(letters: list[Letter]) -> Letter | TreeNode:
total_freq = left.freq + right.freq
node = TreeNode(total_freq, left, right)
response.append(node)
response.sort(key=lambda l: l.freq)
response.sort(key=lambda x: x.freq)
return response[0]


Expand Down
2 changes: 1 addition & 1 deletion data_structures/binary_tree/non_recursive_segment_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def query(self, l: int, r: int) -> T | None: # noqa: E741
l, r = l + self.N, r + self.N

res: T | None = None
while l <= r: # noqa: E741
while l <= r:
if l % 2 == 1:
res = self.st[l] if res is None else self.fn(res, self.st[l])
if r % 2 == 0:
Expand Down
6 changes: 3 additions & 3 deletions data_structures/binary_tree/segment_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def right(self, idx):
return idx * 2 + 1

def build(self, idx, l, r): # noqa: E741
if l == r: # noqa: E741
if l == r:
self.st[idx] = A[l]
else:
mid = (l + r) // 2
Expand All @@ -33,7 +33,7 @@ def update_recursive(self, idx, l, r, a, b, val): # noqa: E741
"""
if r < a or l > b:
return True
if l == r: # noqa: E741
if l == r:
self.st[idx] = val
return True
mid = (l + r) // 2
Expand All @@ -51,7 +51,7 @@ def query_recursive(self, idx, l, r, a, b): # noqa: E741
"""
if r < a or l > b:
return -math.inf
if l >= a and r <= b: # noqa: E741
if l >= a and r <= b:
return self.st[idx]
mid = (l + r) // 2
q1 = self.query_recursive(self.left(idx), l, mid, a, b)
Expand Down
2 changes: 1 addition & 1 deletion machine_learning/sequential_minimum_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def _get_new_alpha(self, i1, i2, a1, a2, e1, e2, y1, y2):
l, h = max(0.0, a2 - a1), min(self._c, self._c + a2 - a1)
else:
l, h = max(0.0, a2 + a1 - self._c), min(self._c, a2 + a1)
if l == h: # noqa: E741
if l == h:
return None, None

# calculate eta
Expand Down
1 change: 0 additions & 1 deletion project_euler/problem_107/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def solution(filename: str = "p107_network.txt") -> int:
"""
script_dir: str = os.path.abspath(os.path.dirname(__file__))
network_file: str = os.path.join(script_dir, filename)
adjacency_matrix: list[list[str]]
edges: dict[EdgeT, int] = {}
data: list[str]
edge1: int
Expand Down