How to use the hacking.core.skip_on_py3 function in hacking

To help you get started, we’ve selected a few hacking examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / hacking / hacking / checks / python23.py View on Github external
@core.skip_on_py3
@core.flake8ext
def hacking_python3x_octal_literals(logical_line, tokens, noqa):
    r"""Check for octal literals in Python 3.x compatible form.

    As of Python 3.x, the construct "0755" has been removed.
    Use "0o755" instead".


    Okay: f(0o755)
    Okay: 'f(0755)'
    Okay: f(755)
    Okay: f(0)
    Okay: f(000)
    Okay: MiB = 1.0415
    H232: f(0755)
    Okay: f(0755)  # noqa
github openstack / hacking / hacking / checks / python23.py View on Github external
@core.skip_on_py3
@core.flake8ext
def hacking_python3x_print_function(logical_line, noqa):
    r"""Check that all print occurrences look like print functions.

    Check that all occurrences of print look like functions, not
    print operator. As of Python 3.x, the print operator has
    been removed.


    Okay: print(msg)
    Okay: print (msg)
    Okay: print msg  # noqa
    Okay: print()
    H233: print msg
    H233: print >>sys.stderr, "hello"
    H233: print msg,
github openstack / hacking / hacking / checks / python23.py View on Github external
@core.skip_on_py3
@core.flake8ext
def hacking_python3x_except_compatible(logical_line, noqa):
    r"""Check for except statements to be Python 3.x compatible

    As of Python 3.x, the construct 'except x,y:' has been removed.
    Use 'except x as y:' instead.


    Okay: try:\n    pass\nexcept Exception:\n    pass
    Okay: try:\n    pass\nexcept (Exception, AttributeError):\n    pass
    H231: try:\n    pass\nexcept AttributeError, e:\n    pass
    Okay: try:\n    pass\nexcept AttributeError, e:  # noqa\n    pass
    """
    if noqa:
        return