Annotation style type (in space or not in space)

Having the following function:

def foo(x=1):
    print(x)

      

The PEP 8 clearly states that around the sign =

should be no spaces, if used to indicate a keyword argument or a default parameter value.

If we want to inject-annotate the parameter x

. How do we do this?

def foo(x:int=1):
def foo(x: int=1):
def foo(x: int = 1):

      

Is there a preferred way? Or even better, is it specified in some PEPs? Didn't find it in PEP 484 .

+3


source to share


1 answer


Examples in PEP 484 use



def foo(x: int = 1):

      

+5


source







All Articles