Skip to content
  • ntome's avatar
    [cragr] introduce yapf-compatible · e822c12a
    ntome authored and hydrargyrum's avatar hydrargyrum committed
    Reformatting was done with:
    
        for f in modules/cragr/**/*.py
        do
            ./tools/hooks/yapf-wo-imports.py -i yapf \
                --style tools/hooks/style.yapf "$f"
        done
    
    For yapf to give pretty code, some manual "hints" were added.
    
    Example 1:
    
        re.compile("some regex around 120 chars")
    
    was reformatted to:
    
        re.
        compile("some regex around 120 chars")
    
    but it can be improved by forcing it to separate param and then
    calling yapf:
    
        re.compile("some regex around 120 chars",)
    
    Example 2:
    
        if long_condition or foo(foo) or bar(bar):
    
    was reformatted to:
    
        if long_condition or foo(
            foo
        ) or bar(bar):
    
    but it can be improved by surrounding the whole condition in
    parentheses, and then calling yapf:
    
        if (long_condition or foo(foo) or bar(bar)):
    e822c12a