py36+: com2ann
This commit is contained in:
@@ -133,7 +133,7 @@ IDENT_PREFIX = "$"
|
||||
|
||||
def expression(s: Scanner) -> ast.Expression:
|
||||
if s.accept(TokenType.EOF):
|
||||
ret = ast.NameConstant(False) # type: ast.expr
|
||||
ret: ast.expr = ast.NameConstant(False)
|
||||
else:
|
||||
ret = expr(s)
|
||||
s.accept(TokenType.EOF, reject=True)
|
||||
@@ -203,9 +203,9 @@ class Expression:
|
||||
:param input: The input expression - one line.
|
||||
"""
|
||||
astexpr = expression(Scanner(input))
|
||||
code = compile(
|
||||
code: types.CodeType = compile(
|
||||
astexpr, filename="<pytest match expression>", mode="eval",
|
||||
) # type: types.CodeType
|
||||
)
|
||||
return Expression(code)
|
||||
|
||||
def evaluate(self, matcher: Callable[[str], bool]) -> bool:
|
||||
@@ -217,7 +217,5 @@ class Expression:
|
||||
|
||||
:returns: Whether the expression matches or not.
|
||||
"""
|
||||
ret = eval(
|
||||
self.code, {"__builtins__": {}}, MatcherAdapter(matcher)
|
||||
) # type: bool
|
||||
ret: bool = eval(self.code, {"__builtins__": {}}, MatcherAdapter(matcher))
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user