From 1bced44f12062b3f05cc74bb551cf9496a4a1178 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:55:59 -0700 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#407) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - https://github.com/charliermarsh/ruff-pre-commit → https://github.com/astral-sh/ruff-pre-commit - [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.5.0) * Apply ruff fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Kevin Phoenix --- .pre-commit-config.yaml | 4 ++-- claripy/backends/backend_smtlib_solvers/__init__.py | 8 ++------ claripy/vsa/bool_result.py | 4 +--- claripy/vsa/strided_interval.py | 13 +++++-------- tests/test_smart_join.py | 4 +--- tests/test_strided_intervals.py | 4 +--- tests/test_vsa.py | 2 +- 7 files changed, 13 insertions(+), 26 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 11ebbacfe..ea179b6a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -93,7 +93,7 @@ repos: - id: check-builtin-literals - id: check-docstring-first -- repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.4.10 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.0 hooks: - id: ruff diff --git a/claripy/backends/backend_smtlib_solvers/__init__.py b/claripy/backends/backend_smtlib_solvers/__init__.py index c44431275..91582ae84 100644 --- a/claripy/backends/backend_smtlib_solvers/__init__.py +++ b/claripy/backends/backend_smtlib_solvers/__init__.py @@ -101,14 +101,10 @@ def _simplify(self, e): return e def _is_false(self, e, extra_constraints=(), solver=None, model_callback=None): - if e.is_constant() and e.constant_value() is False: - return True - return False + return e.is_constant() and e.constant_value() is False def _is_true(self, e, extra_constraints=(), solver=None, model_callback=None): - if e.is_constant() and e.constant_value() is True: - return True - return False + return e.is_constant() and e.constant_value() is True def _batch_eval(self, exprs, n, extra_constraints=(), solver=None, model_callback=None): return [ diff --git a/claripy/vsa/bool_result.py b/claripy/vsa/bool_result.py index d52f81b1b..3d66ec981 100644 --- a/claripy/vsa/bool_result.py +++ b/claripy/vsa/bool_result.py @@ -31,9 +31,7 @@ def identical(self, other): return False if self._op != other._op: return False - if self._args != other._args: - return False - return True + return self._args == other._args def union(self, other): raise NotImplementedError diff --git a/claripy/vsa/strided_interval.py b/claripy/vsa/strided_interval.py index e83eb946b..84b46fe57 100644 --- a/claripy/vsa/strided_interval.py +++ b/claripy/vsa/strided_interval.py @@ -470,9 +470,7 @@ def solution(self, b): "Oops, Strided intervals cannot be passed as parameter to function solution. To implement" ) - if self.intersection(b).is_empty: - return False - return True + return not self.intersection(b).is_empty # # Private methods @@ -1900,17 +1898,16 @@ def _is_surrounded(self, b): elif b.is_top: return True - if ( + return bool( b._surrounds_member(a.lower_bound) and b._surrounds_member(a.upper_bound) and ( - (b.lower_bound == a.lower_bound and b.upper_bound == a.upper_bound) + b.lower_bound == a.lower_bound + and b.upper_bound == a.upper_bound or not a._surrounds_member(b.lower_bound) or not a._surrounds_member(b.upper_bound) ) - ): - return True - return False + ) # # Arithmetic operations diff --git a/tests/test_smart_join.py b/tests/test_smart_join.py index fa7b929f8..7c8028d2c 100644 --- a/tests/test_smart_join.py +++ b/tests/test_smart_join.py @@ -10,9 +10,7 @@ def check_si_fields(si, stride, lb, ub): return False if si.lower_bound != lb: return False - if si.upper_bound != ub: - return False - return True + return si.upper_bound == ub def test_smart_join(): diff --git a/tests/test_strided_intervals.py b/tests/test_strided_intervals.py index 1274c3ac6..e24486199 100644 --- a/tests/test_strided_intervals.py +++ b/tests/test_strided_intervals.py @@ -12,9 +12,7 @@ def check_si_fields(si, stride, lb, ub): return False if si.lower_bound != lb: return False - if si.upper_bound != ub: - return False - return True + return si.upper_bound == ub def test_division(): diff --git a/tests/test_vsa.py b/tests/test_vsa.py index 4d1f2bca0..cf21e93d0 100644 --- a/tests/test_vsa.py +++ b/tests/test_vsa.py @@ -570,7 +570,7 @@ def is_equal(ast_0, ast_1): # ValueSet # - def VS(name=None, bits=None, region=None, val=None): + def VS(name=None, bits=None, region=None, val=None): # noqa: F811 # TODO: Refactor this test case region = "foobar" if region is None else region return claripy.ValueSet(bits, region=region, region_base_addr=0, value=val, name=name)