From 0240f4a4287f9e84f815e6dd668991d7f533edd8 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 10 Jul 2019 18:37:27 +0200 Subject: [PATCH 1/4] Remove unused imports ``` ./other/primelib.py:146:5: F401 'math' imported but unused import math # for function sqrt ^ ./other/primelib.py:500:5: F401 'math.sqrt' imported but unused from math import sqrt ^ ``` --- other/primelib.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/other/primelib.py b/other/primelib.py index c371bc1b9861..f34063a18286 100644 --- a/other/primelib.py +++ b/other/primelib.py @@ -44,7 +44,7 @@ def isPrime(number): input: positive integer 'number' returns true if 'number' is prime otherwise false. """ - import math # for function sqrt + from math import sqrt # precondition assert isinstance(number,int) and (number >= 0) , \ @@ -56,7 +56,7 @@ def isPrime(number): if number <= 1: status = False - for divisor in range(2,int(round(math.sqrt(number)))+1): + for divisor in range(2,int(round(sqrt(number)))+1): # if 'number' divisible by 'divisor' then sets 'status' # of false and break up the loop. @@ -142,8 +142,6 @@ def primeFactorization(number): input: positive integer 'number' returns a list of the prime number factors of 'number' """ - - import math # for function sqrt # precondition assert isinstance(number,int) and number >= 0, \ @@ -496,8 +494,6 @@ def getDivisors(n): # precondition assert isinstance(n,int) and (n >= 1), "'n' must been int and >= 1" - - from math import sqrt ans = [] # will be returned. From 734e7c8091b4eed218197b06716302c723f05695 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 10 Jul 2019 18:42:54 +0200 Subject: [PATCH 2/4] Comment out unused import ``` ./graphs/BFS.py:17:1: F401 'collections' imported but unused import collections ^ ``` --- graphs/BFS.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphs/BFS.py b/graphs/BFS.py index bf9b572cec50..09daddd0f3d9 100644 --- a/graphs/BFS.py +++ b/graphs/BFS.py @@ -14,7 +14,7 @@ """ -import collections +# import collections def bfs(graph, start): From a5ede42e82553e3f950ad8c65013b88d2f3ab5c3 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 10 Jul 2019 18:44:49 +0200 Subject: [PATCH 3/4] Travis CI: Add a flake8 test for unused imports --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0e35fd084268..8f6dbb98f51e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ before_install: pip install --upgrade pip setuptools install: pip install -r requirements.txt before_script: - black --check . || true - - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + - flake8 . --count --select=E9,F401,F63,F7,F82 --show-source --statistics script: - mypy --ignore-missing-imports . #- IGNORE="data_structures,file_transfer_protocol,graphs,machine_learning,maths,neural_network,project_euler" From da51115144a7729a367e6219d3f4d31c1b3bc1e5 Mon Sep 17 00:00:00 2001 From: cclauss Date: Thu, 18 Jul 2019 19:16:21 +0200 Subject: [PATCH 4/4] Update BFS.py --- graphs/BFS.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphs/BFS.py b/graphs/BFS.py index 09daddd0f3d9..bf9b572cec50 100644 --- a/graphs/BFS.py +++ b/graphs/BFS.py @@ -14,7 +14,7 @@ """ -# import collections +import collections def bfs(graph, start):