sparse-intern-71089
10/09/2022, 8:20 PMechoing-dinner-19531
10/09/2022, 8:57 PMclever-painter-96148
10/09/2022, 9:02 PMiam.Role
subclass with default tags. Since `___init___`is overloaded with multiple definitions, it's not clear what is the clean way to achieve this while keeping typing benefits in my subclass?
For reference, I see:
def __init__(__self__,
resource_name: str,
opts: Optional[pulumi.ResourceOptions] = None,
assume_role_policy: Optional[pulumi.Input[str]] = None,
description: Optional[pulumi.Input[str]] = None,
force_detach_policies: Optional[pulumi.Input[bool]] = None,
inline_policies: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['RoleInlinePolicyArgs']]]]] = None,
managed_policy_arns: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
max_session_duration: Optional[pulumi.Input[int]] = None,
name: Optional[pulumi.Input[str]] = None,
name_prefix: Optional[pulumi.Input[str]] = None,
path: Optional[pulumi.Input[str]] = None,
permissions_boundary: Optional[pulumi.Input[str]] = None,
tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
__props__=None):
def __init__(__self__,
resource_name: str,
args: RoleArgs,
opts: Optional[pulumi.ResourceOptions] = None):
def __init__(__self__, resource_name: str, *args, **kwargs):
clever-painter-96148
10/09/2022, 9:04 PMclever-painter-96148
10/09/2022, 9:05 PMCustomRole
the same way I use the original Role
(aka keep all options open) - but that looks hard to achieve?clever-painter-96148
10/09/2022, 9:20 PMclever-painter-96148
10/09/2022, 9:21 PMclever-painter-96148
10/09/2022, 9:35 PMOmit<RoleArgs, 'assumeRolePolicy'>
.
In Python, RoleArgs
is a class, so I don't see any easy way to do that kind of things. And I'd like to avoid writing a ton of boilerplate/redundant code.
Any suggestion?echoing-dinner-19531
10/09/2022, 9:38 PMclever-painter-96148
10/09/2022, 9:41 PMechoing-dinner-19531
10/09/2022, 9:43 PMclever-painter-96148
10/09/2022, 9:43 PMclever-painter-96148
10/09/2022, 9:44 PMechoing-dinner-19531
10/09/2022, 9:44 PMclever-painter-96148
10/09/2022, 9:45 PMechoing-dinner-19531
10/09/2022, 9:45 PMclever-painter-96148
10/09/2022, 9:45 PMechoing-dinner-19531
10/09/2022, 9:46 PMclever-painter-96148
10/09/2022, 9:47 PMclever-painter-96148
10/09/2022, 9:48 PMechoing-dinner-19531
10/09/2022, 9:48 PMechoing-dinner-19531
10/09/2022, 9:49 PMclever-painter-96148
10/09/2022, 9:49 PMclever-painter-96148
10/09/2022, 9:49 PMclever-painter-96148
10/09/2022, 9:52 PMechoing-dinner-19531
10/09/2022, 9:58 PMechoing-dinner-19531
10/09/2022, 9:59 PMclever-painter-96148
10/09/2022, 10:00 PMfierce-ability-58936
10/10/2022, 9:28 PMclever-painter-96148
10/10/2022, 9:40 PMgreat-sunset-355
10/11/2022, 1:19 PMpydantic
but it turned out pretty bad because again Outputs
messed it up. So now I'm writing classes with Attrs
.clever-painter-96148
10/11/2022, 1:22 PMfierce-ability-58936
10/11/2022, 10:38 PMpyright -w
in one console, the same thing as a language server, pytest wth watchexec and everything is nice and tidy.
Pulumi with Python feels much less clunky than Go, for example.
On the other hand, yes, you don't get these features straight from the box, and it involves installing lots of different tools and utilities. I'd personally prefer Go with generics, really looking forward to it!clever-painter-96148
10/12/2022, 7:40 AMclever-painter-96148
10/12/2022, 7:42 AMtype ServiceRoleArgs = Omit<iam.RoleArgs, "assumeRolePolicy"> & {
service: string;
};
Maybe you can achieve the same by metaprogramming Python classes? Don't know. But even if it's possible, it's very complicated.clever-painter-96148
10/12/2022, 7:45 AMTypeScript is awesomee.g. type inference works perfectly across value wrapping/unwrapping. For example,
id
is inferred as a string in TS:
const bucket = new Bucket(...);
bucket.id.apply(id => ...);
But in Python it is `Any`:
bucket = Bucket(...)
bucket.id.apply(lambda id: ...)
echoing-dinner-19531
10/12/2022, 8:43 AMBut in Python it is `Any`:Oooh we should look into that! Python has enough support for generics that I'd expect
id
to be correct there.clever-painter-96148
10/12/2022, 8:44 AMechoing-dinner-19531
10/12/2022, 8:51 AMclever-painter-96148
10/12/2022, 8:58 AMbucket.id.apply(lambda id: id.split())
works.
I must've been doing something more complex.
I'll play a bit with it and raise an issue if I find something weird.clever-painter-96148
10/12/2022, 9:19 AMclever-painter-96148
10/12/2022, 9:19 AMechoing-dinner-19531
10/12/2022, 9:58 AM