Skip to content

Commit 860f384

Browse files
committed
Resolved linting using Flake8
1 parent 92ed0d1 commit 860f384

5 files changed

Lines changed: 61 additions & 28 deletions

File tree

docs/conf.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@
2828

2929
html_static_path = ['_static']
3030
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.venv']
31-
html_sidebars = {'**': ['globaltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html']}
31+
html_sidebars = {
32+
'**': [
33+
'globaltoc.html',
34+
'relations.html',
35+
'sourcelink.html',
36+
'searchbox.html'
37+
]
38+
}

sanatio/number_validator.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ def isDecimal(self, value: float) -> bool:
1212

1313
def isDivisibleBy(self, number: int, divisor: int) -> bool:
1414
""" check if the number is divisible by divisor or not """
15-
return self.isvalidNumber(number) and self.isvalidNumber(divisor) and divisor != 0 and number % divisor == 0
15+
return (self.isvalidNumber(number) and
16+
self.isvalidNumber(divisor) and
17+
divisor != 0 and
18+
number % divisor == 0)
1619

1720
def truncate(self, value: float, digits: int) -> float:
1821
""" truncate the float value """
@@ -59,24 +62,34 @@ def isNonZero(self, value):
5962

6063
def isGreaterThan(self, value, other):
6164
""" check if the value is greater than other or not """
62-
return self.isvalidNumber(value) and self.isvalidNumber(other) and value > other
65+
return (self.isvalidNumber(value) and
66+
self.isvalidNumber(other) and
67+
value > other)
6368

6469
def isGreaterThanOrEqual(self, value, other):
6570
""" check if the value is greater than or equal to other or not """
66-
return self.isvalidNumber(value) and self.isvalidNumber(other) and value >= other
71+
return (self.isvalidNumber(value) and
72+
self.isvalidNumber(other) and
73+
value >= other)
6774

6875
def isLessThan(self, value, other):
6976
""" check if the value is less than other or not """
70-
return self.isvalidNumber(value) and self.isvalidNumber(other) and value < other
77+
return (self.isvalidNumber(value) and
78+
self.isvalidNumber(other) and
79+
value < other)
7180

7281
def isLessThanOrEqual(self, value, other):
7382
""" check if the value is less than or equal to other or not """
74-
return self.isvalidNumber(value) and self.isvalidNumber(other) and value <= other
83+
return (self.isvalidNumber(value) and
84+
self.isvalidNumber(other) and
85+
value <= other)
7586

7687
def isBetween(self, value, min_value, max_value):
7788
""" check if the value is between min_value and max_value or not """
78-
return self.isvalidNumber(value) and self.isvalidNumber(min_value) and \
79-
self.isvalidNumber(max_value) and min_value <= value <= max_value
89+
return (self.isvalidNumber(value) and
90+
self.isvalidNumber(min_value) and
91+
self.isvalidNumber(max_value) and
92+
min_value <= value <= max_value)
8093

8194
def isPrime(self, value) -> bool:
8295
""" check if the value is a prime number or not """
@@ -86,27 +99,29 @@ def isPrime(self, value) -> bool:
8699
if value % i == 0:
87100
return False
88101
return True
89-
102+
90103
def isEven(self, value) -> bool:
91104
""" check if the value is even or not """
92105
return self.isvalidNumber(value) and value % 2 == 0
93-
106+
94107
def isOdd(self, value) -> bool:
95108
""" check if the value is odd or not """
96109
return self.isvalidNumber(value) and value % 2 != 0
97-
110+
98111
def isMultipleOf(self, value, multiple) -> bool:
99112
""" check if the value is a multiple of another number """
100-
if not self.isvalidNumber(value) or not self.isvalidNumber(multiple) or multiple == 0:
113+
if (not self.isvalidNumber(value) or
114+
not self.isvalidNumber(multiple) or
115+
multiple == 0):
101116
return False
102117
return value % multiple == 0
103-
118+
104119
def isSquare(self, value) -> bool:
105120
""" Check if the value is a perfect square or not """
106121
if not self.isvalidNumber(value):
107122
return False
108123
if value < 0:
109-
return False # Negative numbers cannot be perfect squares.
124+
return False
110125
square_root = round(value ** 0.5)
111126
return square_root ** 2 == value
112127

tests/document/aadhar_card_test.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import unittest
3-
sys.path.append('.')
43
from sanatio import Sanatio
4+
sys.path.append('.')
55

66
validator = Sanatio()
77

@@ -10,13 +10,21 @@ class AadharCardTest(unittest.TestCase):
1010
def test_isAadharCard_True(self):
1111
self.assertTrue(validator.isAadharCard('9284 9436 2499'))
1212
self.assertTrue(validator.isAadharCard(' 9284 9436 2499 '))
13-
13+
1414
def test_isAadharCard_False(self):
15-
self.assertFalse(validator.isAadharCard('9284 9436 2493')) # checksum false
15+
self.assertFalse(
16+
validator.isAadharCard('9284 9436 2493')
17+
) # checksum false
1618
self.assertFalse(validator.isAadharCard('9284 9436 249')) # too short
17-
self.assertFalse(validator.isAadharCard('9284 9436 24999')) # too long
18-
self.assertFalse(validator.isAadharCard('1234 5678 9012')) # starts with 0/1
19-
self.assertFalse(validator.isAadharCard('9284 9436 249a')) # contains non-digit
20-
19+
self.assertFalse(
20+
validator.isAadharCard('9284 9436 24999')
21+
) # too long
22+
self.assertFalse(
23+
validator.isAadharCard('1234 5678 9012')) # starts with 0/1
24+
self.assertFalse(
25+
validator.isAadharCard('9284 9436 249a')
26+
) # contains non-digit
27+
28+
2129
if __name__ == '__main__':
22-
unittest.main()
30+
unittest.main()

tests/document/credit_card_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import unittest
3-
sys.path.append('.')
43
from sanatio import Sanatio
4+
sys.path.append('.')
55

66
validator = Sanatio()
77

@@ -11,10 +11,12 @@ def test_credit_card_true(self):
1111
self.assertTrue(validator.isCreditCard('4578423013769219'))
1212
self.assertTrue(validator.isCreditCard('4569403961014710'))
1313
self.assertTrue(validator.isCreditCard('6011000990139424'))
14-
14+
1515
def test_credit_card_false(self):
16-
self.assertFalse(validator.isCreditCard('370341378581368')) # checksome false
16+
self.assertFalse(
17+
validator.isCreditCard('370341378581368')
18+
) # checksome false
1719

1820

1921
if __name__ == '__main__':
20-
unittest.main()
22+
unittest.main()

tests/number_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import unittest
3-
sys.path.append('.')
43
from sanatio import Sanatio
4+
sys.path.append('.')
55

66
validator = Sanatio()
77

@@ -284,5 +284,6 @@ def test_isCube_false(self):
284284
self.assertFalse(validator.isCube(-23))
285285
self.assertFalse(validator.isCube(-100))
286286

287+
287288
if __name__ == '__main__':
288-
unittest.main()
289+
unittest.main()

0 commit comments

Comments
 (0)