Skip to content

Commit

Permalink
lint: resolve bandit issues
Browse files Browse the repository at this point in the history
  • Loading branch information
marcofavorito committed May 13, 2023
1 parent af16cd4 commit 010c75a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pddl/parser/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def domain(self, args):
elif isinstance(arg, DerivedPredicate):
derived_predicates.append(arg)
else:
assert isinstance(arg, dict)
assert_(isinstance(arg, dict))
kwargs.update(arg)
kwargs.update(actions=actions, derived_predicates=derived_predicates)
return Domain(**kwargs)
Expand Down Expand Up @@ -249,7 +249,7 @@ def cond_effect(self, args):
if len(args) >= 3 and args[1] == Symbols.AND.value:
p_effects = args[2:-1]
return And(*p_effects)
assert len(args) == 1
assert_(len(args) == 1)
return args[0]

def atomic_formula_term(self, args):
Expand Down
10 changes: 6 additions & 4 deletions pddl/parser/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from lark import Lark, ParseError, Transformer

from pddl.core import Problem, Requirements
from pddl.helpers.base import assert_
from pddl.logic.base import And, Not
from pddl.logic.predicates import EqualTo, Predicate
from pddl.logic.terms import Constant
Expand All @@ -43,9 +44,10 @@ def start(self, args):
def problem(self, args):
"""Process the 'problem' rule."""
args = [arg for arg in args if arg is not None]
assert (
args[0].value + args[1].value + args[-1].value == "(define)"
), "Problem should start with '(define' and close with ')'"
assert_(
(args[0].value + args[1].value + args[-1].value == "(define)"),
"Problem should start with '(define' and close with ')'",
)
return Problem(**dict(args[2:-1]))

def problem_def(self, args):
Expand Down Expand Up @@ -82,7 +84,7 @@ def typed_list_name(self, args):

def domain__type_def(self, names):
"""Process a domain type def."""
assert len(names) == 1
assert_(len(names) == 1)
return str(names[0])

def init(self, args):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_helpers/test_cache_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#

"""Test the cache hash class decorator."""
import pickle
import pickle # nosec

from pddl.helpers.cache_hash import cache_hash

Expand Down Expand Up @@ -45,6 +45,6 @@ def test_hashable():
assert hasattr(obj, "__hash")
assert obj.__hash == h1 == h2

dumped_obj = pickle.dumps(obj)
actual_obj = pickle.loads(dumped_obj)
dumped_obj = pickle.dumps(obj) # nosec
actual_obj = pickle.loads(dumped_obj) # nosec
assert not hasattr(actual_obj, "__hash")

0 comments on commit 010c75a

Please sign in to comment.