nikaro

joined 2 years ago
[–] nikaro@jlai.lu 4 points 1 year ago

Nice! It looks like the best solution out there.

[–] nikaro@jlai.lu 4 points 1 year ago* (last edited 1 year ago)

Python >= 3.10 version:

def foo(return_more: bool) -> DataType | tuple[DataType, MoreDataType]: ...

But i would definitely avoid to do that if possible. I would maybe do something like this instead:

def foo(return_more: bool) -> tuple[DataType, MoreDataType | None]:
    ...
    if return_more:
        return data, more_data
   return data, None

Or if data is a dict, just update it with more_data:

def foo(return_more: bool) -> dict[str, Any]:
    ...
    if return_more:
        return data.update(more_data)
   return data
[–] nikaro@jlai.lu 1 points 1 year ago

The difference is that with Protocol you can define which method presence you want to ensure. Like i said: custom vs. generic.

[–] nikaro@jlai.lu 1 points 1 year ago (2 children)

From what i understand, Protocol is for custom interfaces that you define (this object must have do_x() method), while ABCs are generic (this object is iterable).

[–] nikaro@jlai.lu 2 points 1 year ago

Yup, that's what i would also do.

[–] nikaro@jlai.lu 0 points 1 year ago (1 children)

Yeah we are better served with pedantic nerds that thinks they know IaC better than some top engineer at an IaC vendor 🤷

[–] nikaro@jlai.lu 1 points 1 year ago

Ok i think i get the point. A "generic programming language" could be used as a "domain specific language" in some context. Is that what you mean?

[–] nikaro@jlai.lu 1 points 1 year ago (2 children)
[–] nikaro@jlai.lu 0 points 1 year ago (3 children)

The author seems fully aware of the existence CDKTF, and by invest i think he means that they should privilege it instead of HCL. The point is that if you learn Python, it is reusable somewhere else. If you learn HCL, you learned a vendor language, it is only used in Terraform.

[–] nikaro@jlai.lu 0 points 2 years ago* (last edited 2 years ago) (5 children)

The author is actually fine with CDK, since it uses an actual programming language. That's the point of the article.

By the way, on a personal note, Terraform is still bad to my eyes since their license change.

[–] nikaro@jlai.lu 1 points 2 years ago

I'm in the process of migrating to Pulumi, i like it so far.

[–] nikaro@jlai.lu -1 points 2 years ago (7 children)

You can use if instead of the ugly count hack in HCL... 🤷‍♂️

view more: ‹ prev next ›