From 6571ada9a2f26b4cb1ef3e48196864ff577480b4 Mon Sep 17 00:00:00 2001 From: Josselin Feist Date: Mon, 3 Oct 2022 10:57:48 +0200 Subject: [PATCH] run black --- slither/core/solidity_types/elementary_type.py | 6 +++--- .../detectors/naming_convention/naming_convention.py | 12 ++++-------- slither/detectors/statements/type_based_tautology.py | 2 +- slither/slithir/convert.py | 4 ++-- slither/visitors/expression/constants_folding.py | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/slither/core/solidity_types/elementary_type.py b/slither/core/solidity_types/elementary_type.py index c6804f9c1..fc248e946 100644 --- a/slither/core/solidity_types/elementary_type.py +++ b/slither/core/solidity_types/elementary_type.py @@ -43,8 +43,8 @@ Int = [ "int256", ] -Max_Int = {k: 2 ** (8 * i - 1) - 1 if i > 0 else 2 ** 255 - 1 for i, k in enumerate(Int)} -Min_Int = {k: -(2 ** (8 * i - 1)) if i > 0 else -(2 ** 255) for i, k in enumerate(Int)} +Max_Int = {k: 2 ** (8 * i - 1) - 1 if i > 0 else 2**255 - 1 for i, k in enumerate(Int)} +Min_Int = {k: -(2 ** (8 * i - 1)) if i > 0 else -(2**255) for i, k in enumerate(Int)} Uint = [ "uint", @@ -82,7 +82,7 @@ Uint = [ "uint256", ] -Max_Uint = {k: 2 ** (8 * i) - 1 if i > 0 else 2 ** 256 - 1 for i, k in enumerate(Uint)} +Max_Uint = {k: 2 ** (8 * i) - 1 if i > 0 else 2**256 - 1 for i, k in enumerate(Uint)} Min_Uint = {k: 0 for k in Uint} diff --git a/slither/detectors/naming_convention/naming_convention.py b/slither/detectors/naming_convention/naming_convention.py index 2cca9dee9..706f4ae6c 100644 --- a/slither/detectors/naming_convention/naming_convention.py +++ b/slither/detectors/naming_convention/naming_convention.py @@ -89,14 +89,10 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 if func.is_constructor: continue if not self.is_mixed_case(func.name): - if ( - func.visibility - in [ - "internal", - "private", - ] - and self.is_mixed_case_with_underscore(func.name) - ): + if func.visibility in [ + "internal", + "private", + ] and self.is_mixed_case_with_underscore(func.name): continue if func.name.startswith(("echidna_", "crytic_")): continue diff --git a/slither/detectors/statements/type_based_tautology.py b/slither/detectors/statements/type_based_tautology.py index efa814713..0129ad03f 100644 --- a/slither/detectors/statements/type_based_tautology.py +++ b/slither/detectors/statements/type_based_tautology.py @@ -11,7 +11,7 @@ from slither.core.solidity_types.elementary_type import Int, Uint def typeRange(t): bits = int(t.split("int")[1]) if t in Uint: - return 0, (2 ** bits) - 1 + return 0, (2**bits) - 1 if t in Int: v = (2 ** (bits - 1)) - 1 return -v, v diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index e851acfcc..818959afb 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -172,10 +172,10 @@ def _fits_under_integer(val: int, can_be_int: bool, can_be_uint) -> List[str]: assert can_be_int | can_be_uint while n <= 256: if can_be_uint: - if val <= 2 ** n - 1: + if val <= 2**n - 1: ret.append(f"uint{n}") if can_be_int: - if val <= (2 ** n) / 2 - 1: + if val <= (2**n) / 2 - 1: ret.append(f"int{n}") n = n + 8 return ret diff --git a/slither/visitors/expression/constants_folding.py b/slither/visitors/expression/constants_folding.py index 250104f5e..b324ed842 100644 --- a/slither/visitors/expression/constants_folding.py +++ b/slither/visitors/expression/constants_folding.py @@ -43,7 +43,7 @@ class ConstantFolding(ExpressionVisitor): left = get_val(expression.expression_left) right = get_val(expression.expression_right) if expression.type == BinaryOperationType.POWER: - set_val(expression, left ** right) + set_val(expression, left**right) elif expression.type == BinaryOperationType.MULTIPLICATION: set_val(expression, left * right) elif expression.type == BinaryOperationType.DIVISION: