Skip to content

Commit

Permalink
🚨 Fix or ignore bandit errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TeoZosa committed Sep 20, 2022
1 parent 5d3c910 commit 7af4f37
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion pytudes/_2021/coderbyte/math_challenge__hard.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def MathChallenge(rpn_expression: str) -> int:
curr_num = curr_num * 10 + int(token)

# Add number from fully-parsed multi-digit string to operand stack
elif token == " " and curr_num is not None: # Operand/operator delimiter
elif (
token == " " and curr_num is not None # Operand/operator delimiter # nosec
):
operand_stack.append(curr_num)
curr_num = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def compute_topological_orders(
for child in graph[curr_source_vertex]: # 3
in_degree[child] += 1
unpop = acc_topological_order.pop() # 2
assert unpop == curr_source_vertex
assert unpop == curr_source_vertex # nosec
sources.append(curr_source_vertex) # 1

return topological_orders
4 changes: 2 additions & 2 deletions pytudes/_2021/leetcode/hard/_224_basic_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def move_greater_or_equal_precedence_operators_in_curr_scope_to_rpn_stack() -> N

# Update operators in intermediate stack/Move to RPN stack
if token in operator_precedence:
if token != "(":
if token != "(": # nosec
move_greater_or_equal_precedence_operators_in_curr_scope_to_rpn_stack()
if token != ")":
if token != ")": # nosec
intermediate_operator_tokens.append(token)

rpn_tokens += reversed(intermediate_operator_tokens)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ def eval_RPN_classic(tokens: list[str]) -> int:
for token in tokens:
if token in arithmetic_operators:
right_operand, left_operand = operand_stack.pop(), operand_stack.pop()
if token == "+":
if token == "+": # nosec
new_operand = left_operand + right_operand
elif token == "-":
elif token == "-": # nosec
new_operand = left_operand - right_operand
elif token == "*":
elif token == "*": # nosec
new_operand = left_operand * right_operand
else: # token == "/"
# Integer division is truncated toward zero.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def swap_elements(i, j) -> None:
get_distance = lambda i: sum(coord**2 for coord in points[i])

## INITIALIZE VARS ##
pivot_idx = random.randint(start, end) # inclusive range
pivot_idx = random.randint(start, end) # inclusive range # nosec
pivot_distance = get_distance(pivot_idx)

## 3-WAY PARTITION ##
Expand Down Expand Up @@ -209,7 +209,7 @@ def swap_elements(i, j) -> None:
while start < end: # pragma: no branch

## INITIALIZE VARS ##
pivot_idx = random.randint(start, end) # inclusive range
pivot_idx = random.randint(start, end) # inclusive range # nosec
pivot_distance = get_distance(pivot_idx)

## 3-WAY PARTITION ##
Expand Down
4 changes: 2 additions & 2 deletions pytudes/_2021/miscellany/bit_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def set_negation(A: int) -> int:
"""
normal_neg = ~A
XOR_neg = A ^ all_1_bits() # ~0
assert normal_neg == XOR_neg == -A - 1
assert normal_neg == XOR_neg == -A - 1 # nosec
return normal_neg


Expand Down Expand Up @@ -334,7 +334,7 @@ def extract_last_bit(A: int) -> int:
mask_with_twos_complement_negation_of_A = A & -A
mask_with_negation_of_A_minus_1 = A & ~(A - 1)
XOR_with_A_last_on_bit_dropped = A ^ remove_last_on_bit(A) # A ^ (A & (A - 1))
assert (
assert ( # nosec
mask_with_twos_complement_negation_of_A
== mask_with_negation_of_A_minus_1
== XOR_with_A_last_on_bit_dropped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def swap_elements(i, j):
return

## INITIALIZE VARS ##
pivot_idx = random.randint(start, end)
pivot_idx = random.randint(start, end) # nosec
pivot = items[pivot_idx]

## 3-WAY PARTITION ##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def swap_elements(i, j):
items[i], items[j] = items[j], items[i]

## INITIALIZE VARS ##
pivot_idx = random.randint(start, end)
pivot_idx = random.randint(start, end) # nosec
pivot = items[pivot_idx]

## 3-WAY PARTITION ##
Expand Down

0 comments on commit 7af4f37

Please sign in to comment.