PY-16050 Formatter inserts exactly one space after ":" and "->" in annotations

This commit is contained in:
Mikhail Golubev
2015-05-27 22:45:01 +03:00
parent df512e8b7d
commit 6b5ea8f750
7 changed files with 12 additions and 8 deletions
@@ -99,6 +99,8 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
.betweenInside(MINUS, GT, ANNOTATION).none()
.beforeInside(ANNOTATION, FUNCTION_DECLARATION).spaces(1)
.beforeInside(ANNOTATION, NAMED_PARAMETER).none()
.afterInside(COLON, ANNOTATION).spaces(1)
.afterInside(RARROW, ANNOTATION).spaces(1)
.between(allButLambda(), PARAMETER_LIST).spaceIf(commonSettings.SPACE_BEFORE_METHOD_PARENTHESES)
@@ -1,2 +1,2 @@
def foo(x : int):
def foo(x : int) -> object:
pass
@@ -1,2 +1,2 @@
def foo(x: int):
def foo(x: int) -> object:
pass
@@ -4,6 +4,6 @@ class A:
class B(A):
def __init__(this:'B', y, x):
def __init__(this: 'B', y, x):
super().__init__(x)
this.y = y
@@ -3,5 +3,5 @@ class A:
pass
class B(A):
def __init__(self, d:str, a:int, b:float, *args:tuple, e:bytes, c:complex, **kwargs:dict) -> list:
def __init__(self, d: str, a: int, b: float, *args: tuple, e: bytes, c: complex, **kwargs: dict) -> list:
super().__init__(a, b, *args, c=c, **kwargs)
@@ -5,6 +5,7 @@ class ArgsTest:
comment:str=None, version:int=None): pass
class Sub(ArgsTest):
def __init__(self, key:str=None, value:str=None, max_age=None, expires=None, path:str=None, domain:str=None,
secure:bool=False, httponly:bool=False, sync_expires:bool=True, comment:str=None, version:int=None):
<selection>super().__init__(key, value, max_age, expires, path, domain, secure, httponly, sync_expires, comment, version)</selection>
def __init__(self, key: str=None, value: str=None, max_age=None, expires=None, path: str=None, domain: str=None,
secure: bool=False, httponly: bool=False, sync_expires: bool=True, comment: str=None,
version: int=None):
super().__init__(key, value, max_age, expires, path, domain, secure, httponly, sync_expires, comment, version)
@@ -351,7 +351,8 @@ public class PyFormatterTest extends PyTestCase {
}
}
public void testSpaceInAnnotations() { // PY-8961
// PY-8961, PY-16050
public void testSpaceInAnnotations() {
doTestPy3();
}