OILS / mycpp / examples / invalid_default_args.py View on Github | oilshell.org

44 lines, 18 significant
1#!/usr/bin/env python2
2"""
3invalid_too_many_defaults.py
4"""
5from __future__ import print_function
6
7from typing import List
8
9
10def ok_None(x=None):
11 # type: (str) -> None
12 pass
13
14
15def ok_bool(x=False):
16 # type: (bool) -> None
17 pass
18
19
20def too_many_defaults(x, y=4, z=5):
21 # type: (int, int, int) -> None
22 pass
23
24
25# I think we should allow None, bool, and int
26def mutable_default(x, y=[]):
27 # type: (int, List[int]) -> None
28 pass
29
30
31class TooManyDefaults(object):
32
33 def __init__(self, x, y=42, z=5):
34 # type: (int, int, int) -> None
35 self.x = x
36 self.y = y
37
38
39class MutableDefault(object):
40
41 def __init__(self, x, y=42, z=[]):
42 # type: (int, int, List[int]) -> None
43 self.x = x
44 self.y = y