diff --git a/demo_code.py b/demo_code.py index 5b882bb0a..0c58d1481 100644 --- a/demo_code.py +++ b/demo_code.py @@ -9,6 +9,7 @@ AWS_SECRET_KEY = "d6s$f9g!j8mg7hw?n&2" + class BaseNumberGenerator: """Declare a method -- `get_number`.""" @@ -43,6 +44,7 @@ def get_number(self, min_max=[1, 10]): class ImaginaryNumber: """Class to represent an imaginary number.""" + def __init__(self): self.real = 0 self.imaginary = 1 @@ -126,11 +128,13 @@ def chained_comparison(): c = 3 return a < b and b < c + def wrong_callable(): number = ImaginaryNumber() - if hasattr(number, '__call__'): + if hasattr(number, "__call__"): return number() + if __name__ == "__main__": args = ["--disable", "all"] for i in range(len(args)): diff --git a/django_issues.py b/django_issues.py index a0d19177b..34acf9ff4 100644 --- a/django_issues.py +++ b/django_issues.py @@ -3,7 +3,8 @@ from django.http import HttpResponse from django.views.decorators.http import require_http_methods -@require_http_methods(["GET", "POST"]) # Sensitive + +@require_http_methods(["GET", "POST"]) # Sensitive def current_datetime(request): now = datetime.datetime.now() html = "It is %s." % now diff --git a/foo.py b/foo.py index f1cd62290..586f4804d 100644 --- a/foo.py +++ b/foo.py @@ -1,4 +1,5 @@ def abc(b=None): + breakpoint() if b is None: b = [] print(b) diff --git a/miscellaneous.py b/miscellaneous.py index 4bdbd5649..1e8f1564b 100644 --- a/miscellaneous.py +++ b/miscellaneous.py @@ -1,23 +1,28 @@ from utils import get_next, render_to_frontend, render_bg + class Orange: """Represents the fruit orange.""" + orange = "#FFA500" - + # Other class implementations - + def get_orange(self): return self.orange + def render(): fruit = Orange() - render_to_frontend(fruit.orange) # Rendering a color, but one can get confused with the fruit + render_to_frontend( + fruit.orange + ) # Rendering a color, but one can get confused with the fruit render_bg(fruit.get_orange) + def play_with_magic_numbers(): magic_numbers = {0, 1, 1, 2, 3, 5} for elem in magic_numbers.copy(): magic_numbers.add(get_next(elem)) return magic_numbers - diff --git a/return_not_implemented.py b/return_not_implemented.py index a77f493d5..5fa47dd0a 100644 --- a/return_not_implemented.py +++ b/return_not_implemented.py @@ -1,24 +1,28 @@ class RealNumber: """Represents a real number.""" - def __init__(self, val): - self.val = val - - def __add__(self, other): + + def __init__(self, val): + self.val = val + + def __add__(self, other): raise NotImplementedError - + + class ComplexNumber: """Represents an imaginary number.""" - def __init__(self, x, y): + + def __init__(self, x, y): self.x = x - self.y = y - - def __add__(self, other): - return self.val + other.val - - def __radd__(self, other): - res = (self.x + other.val, self.y) + self.y = y + + def __add__(self, other): + return self.val + other.val + + def __radd__(self, other): + res = (self.x + other.val, self.y) return res + if __name__ == "__main__": complex_num = ComplexNumber(2, 5) real_num = RealNumber(32) diff --git a/security.py b/security.py index 1916df298..b8b179b51 100644 --- a/security.py +++ b/security.py @@ -1,6 +1,7 @@ import sqlite3 import requests + class ResidentsDb: def __init__(self, table_name, mapping_function, duration): """Set location on disk data cache will reside. @@ -14,16 +15,19 @@ def __init__(self, table_name, mapping_function, duration): self.cursor = None def open(self): - """ Opens connection to sqlite database.""" + """Opens connection to sqlite database.""" self.conn = sqlite3.connect(self.dbname) self.cursor = self.conn.cursor() def get_id_from_name(self, name): """Get id of resident from name.""" - data = self.cursor.execute("SELECT id FROM userdata WHERE Name ={};".format(name)) + data = self.cursor.execute( + "SELECT id FROM userdata WHERE Name ={};".format(name) + ) self.conn.commit() return data + def fetch_version(request): """Fetch verison of bgmi.""" version = requests.get( diff --git a/tests/test_code.py b/tests/test_code.py index 159c78dfb..ee6cfbf13 100644 --- a/tests/test_code.py +++ b/tests/test_code.py @@ -6,6 +6,7 @@ def test_random_number_generator(): """Test random number generator.""" assert RandomNumberGenerator().get_number() + class Tests(unittest.TestCase): def my_test(self, arg1, arg2): self.assertEquals(arg1, arg2) diff --git a/type_checks.py b/type_checks.py index 811da988f..766e84441 100644 --- a/type_checks.py +++ b/type_checks.py @@ -1,6 +1,7 @@ def greet_all(names: list[str]) -> None: for name in names: - print('Hello ' + name) + print("Hello " + name) + if __name__ == "__main__": heights = [5.5, 6, 5.9]