From 57e6301e26baa80661e3462a481ef3ed8c0646c0 Mon Sep 17 00:00:00 2001 From: deepsourcebot Date: Fri, 9 Jun 2023 11:59:36 +0000 Subject: [PATCH 1/2] Change methods not using its bound instance to staticmethods The method doesn't use its bound instance. Decorate this method with `@staticmethod` decorator, so that Python does not have to instantiate a bound method for every instance of this class thereby saving memory and computation. Read more about staticmethods [here](https://docs.python.org/3/library/functions.html#staticmethod). --- demo_code.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demo_code.py b/demo_code.py index 275fda452..ed5a63e7e 100644 --- a/demo_code.py +++ b/demo_code.py @@ -40,7 +40,8 @@ def limits(self): a = 2 return self.limits - def get_number(self, min_max=[1, 10]): + @staticmethod + def get_number(min_max=[1, 10]): """Get a random number between min and max.""" collections assert all([isinstance(i, int) for i in min_max]) From 9c799f98458bd83d83b41bd84d9f82d68b4854fa Mon Sep 17 00:00:00 2001 From: deepsourcebot Date: Fri, 9 Jun 2023 11:59:45 +0000 Subject: [PATCH 2/2] format code with Black and ISort This commit fixes the style issues introduced in 57e6301 according to the output from Black and ISort. Details: --- demo_code.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/demo_code.py b/demo_code.py index ed5a63e7e..e12351352 100644 --- a/demo_code.py +++ b/demo_code.py @@ -1,10 +1,10 @@ -import random -import sys as sys +import collections import os -import subprocess -import ssl import pprint -import collections +import random +import ssl +import subprocess +import sys as sys import this