Skip to content

Commit f668828

Browse files
Format code with black
This commit fixes the style issues introduced in 7d83c66 according to the output from black. Details: https://deepsource.icu/gh/eshaan-test-org/demo-python/transform/88e729d3-713a-4df4-98e6-85449ce75ed1/
1 parent 7d83c66 commit f668828

7 files changed

+42
-22
lines changed

demo_code.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
AWS_SECRET_KEY = "d6s$f9g!j8mg7hw?n&2"
1212

13+
1314
class BaseNumberGenerator:
1415
"""Declare a method -- `get_number`."""
1516

@@ -44,6 +45,7 @@ def get_number(self, min_max=[1, 10]):
4445

4546
class ImaginaryNumber:
4647
"""Class to represent an imaginary number."""
48+
4749
def __init__(self):
4850
self.real = 0
4951
self.imaginary = 1
@@ -128,11 +130,13 @@ def chained_comparison():
128130
c = 3
129131
return a < b and b < c
130132

133+
131134
def wrong_callable():
132135
number = ImaginaryNumber()
133-
if hasattr(number, '__call__'):
136+
if hasattr(number, "__call__"):
134137
return number()
135138

139+
136140
if __name__ == "__main__":
137141
args = ["--disable", "all"]
138142
for i in range(len(args)):

django_issues.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from django.http import HttpResponse
44
from django.views.decorators.http import require_http_methods
55

6-
@require_http_methods(["GET", "POST"]) # Sensitive
6+
7+
@require_http_methods(["GET", "POST"]) # Sensitive
78
def current_datetime(request):
89
now = datetime.datetime.now()
910
html = "<html><body>It is %s.</body></html>" % now

miscellaneous.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
from utils import get_next, render_to_frontend, render_bg
22

3+
34
class Orange:
45
"""Represents the fruit orange."""
6+
57
orange = "#FFA500"
6-
8+
79
# Other class implementations
8-
10+
911
def get_orange(self):
1012
return self.orange
1113

14+
1215
def render():
1316
fruit = Orange()
14-
render_to_frontend(fruit.orange) # Rendering a color, but one can get confused with the fruit
17+
render_to_frontend(
18+
fruit.orange
19+
) # Rendering a color, but one can get confused with the fruit
1520
render_bg(fruit.get_orange)
1621

22+
1723
def play_with_magic_numbers():
1824
magic_numbers = {0, 1, 1, 2, 3, 5}
1925

2026
for elem in magic_numbers:
2127
magic_numbers.add(get_next(elem))
2228
return magic_numbers
23-

return_not_implemented.py

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
class RealNumber:
22
"""Represents a real number."""
3-
def __init__(self, val):
4-
self.val = val
5-
6-
def __add__(self, other):
3+
4+
def __init__(self, val):
5+
self.val = val
6+
7+
def __add__(self, other):
78
raise NotImplementedError
8-
9+
10+
911
class ComplexNumber:
1012
"""Represents an imaginary number."""
11-
def __init__(self, x, y):
13+
14+
def __init__(self, x, y):
1215
self.x = x
13-
self.y = y
14-
15-
def __add__(self, other):
16-
return self.val + other.val
17-
18-
def __radd__(self, other):
19-
res = (self.x + other.val, self.y)
16+
self.y = y
17+
18+
def __add__(self, other):
19+
return self.val + other.val
20+
21+
def __radd__(self, other):
22+
res = (self.x + other.val, self.y)
2023
return res
2124

25+
2226
if __name__ == "__main__":
2327
complex_num = ComplexNumber(2, 5)
2428
real_num = RealNumber(32)

security.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sqlite3
22
import requests
33

4+
45
class ResidentsDb:
56
def __init__(self, table_name, mapping_function, duration):
67
"""Set location on disk data cache will reside.
@@ -14,16 +15,19 @@ def __init__(self, table_name, mapping_function, duration):
1415
self.cursor = None
1516

1617
def open(self):
17-
""" Opens connection to sqlite database."""
18+
"""Opens connection to sqlite database."""
1819
self.conn = sqlite3.connect(self.dbname)
1920
self.cursor = self.conn.cursor()
2021

2122
def get_id_from_name(self, name):
2223
"""Get id of resident from name."""
23-
data = self.cursor.execute("SELECT id FROM userdata WHERE Name ={};".format(name))
24+
data = self.cursor.execute(
25+
"SELECT id FROM userdata WHERE Name ={};".format(name)
26+
)
2427
self.conn.commit()
2528
return data
2629

30+
2731
def fetch_version(request):
2832
"""Fetch verison of bgmi."""
2933
version = requests.get(

tests/test_code.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def test_random_number_generator():
66
"""Test random number generator."""
77
assert RandomNumberGenerator().get_number()
88

9+
910
class Tests(unittest.TestCase):
1011
def my_test(self, arg1, arg2):
1112
self.assertEquals(arg1, arg2)

type_checks.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
def greet_all(names: list[str]) -> None:
22
for name in names:
3-
print('Hello ' + name)
3+
print("Hello " + name)
4+
45

56
if __name__ == "__main__":
67
heights = [5.5, 6, 5.9]

0 commit comments

Comments
 (0)