Fix some warnings from LGTM (#2420)

* fix assignment of a variable to itself

* Fix unnecessary 'else' clause in loop

* formatting and redundant reasignment fix

* mark unreachable code with a TODO comment

* fix variable defined multiple times

* fix static method without static decorator

* revert unintended autoformatting

Co-authored-by: Christian Clauss <cclauss@me.com>

* revert autoformatting issue

* applied black autoformatting

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Hasenn 2020-09-13 10:11:27 +02:00 committed by GitHub
parent f754c0d31f
commit 20e98fcded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 6 deletions

View File

@ -218,7 +218,6 @@ def enigma(
rotorpos1 -= 1
rotorpos2 -= 1
rotorpos3 -= 1
plugboard = plugboard
result = []

View File

@ -226,6 +226,7 @@ class DirectedGraph:
break
else:
return True
# TODO:The following code is unreachable.
anticipating_nodes.add(stack[len_stack_minus_one])
len_stack_minus_one -= 1
if visited.count(node[1]) < 1:
@ -453,6 +454,8 @@ class Graph:
break
else:
return True
# TODO: the following code is unreachable
# is this meant to be called in the else ?
anticipating_nodes.add(stack[len_stack_minus_one])
len_stack_minus_one -= 1
if visited.count(node[1]) < 1:

View File

@ -146,6 +146,7 @@ class Graph:
self.parent[root2] = root1
return root1
@staticmethod
def boruvka_mst(graph):
"""
Implementation of Boruvka's algorithm

View File

@ -44,7 +44,6 @@ def pi(precision: int) -> str:
getcontext().prec = precision
num_iterations = ceil(precision / 14)
constant_term = 426880 * Decimal(10005).sqrt()
multinomial_term = 1
exponential_term = 1
linear_term = 13591409
partial_sum = Decimal(linear_term)

View File

@ -61,7 +61,6 @@ def triplet_sum2(arr: List[int], target: int) -> Tuple[int, int, int]:
left += 1
elif arr[i] + arr[left] + arr[right] > target:
right -= 1
else:
return (0, 0, 0)

View File

@ -11,7 +11,6 @@ import pandas as pd
def calculate_waitingtime(
arrival_time: List[int], burst_time: List[int], no_of_processes: int
) -> List[int]:
"""
Calculate the waiting time of each processes
Return: list of waiting times.
@ -126,13 +125,16 @@ if __name__ == "__main__":
for i in range(no_of_processes):
print("Enter the arrival time and brust time for process:--" + str(i + 1))
arrival_time[i], burst_time[i] = map(int, input().split())
waiting_time = calculate_waitingtime(arrival_time, burst_time, no_of_processes)
bt = burst_time
n = no_of_processes
wt = waiting_time
turn_around_time = calculate_turnaroundtime(bt, n, wt)
calculate_average_times(waiting_time, turn_around_time, no_of_processes)
processes = list(range(1, no_of_processes + 1))
fcfs = pd.DataFrame(
list(zip(processes, burst_time, arrival_time, waiting_time, turn_around_time)),
columns=[