Python ast.unaryop() Examples
The following are 1
code examples of ast.unaryop().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ast
, or try the search function
.
Example #1
Source File: operators.py From wemake-python-styleguide with MIT License | 5 votes |
def count_unary_operator( node: ast.AST, operator: Type[ast.unaryop], amount: int = 0, ) -> int: """Returns amount of unary operators matching input.""" parent = get_parent(node) if parent is None or not isinstance(parent, ast.UnaryOp): return amount if isinstance(parent.op, operator): return count_unary_operator(parent, operator, amount + 1) return count_unary_operator(parent, operator, amount)