Generated objects in python have unreal names - th...
# python
g
Generated objects in python have unreal names - this is not pythonic it looks like Java or C# at best 😞
Copy code
ServiceSourceConfigurationAuthenticationConfigurationArgs
Is there any chance to remedy this? without dropping into dictionaries? PEP8 python line length suggest 79 characters the name above is 57!
r
What’s your suggestion?
g
first at least drop the suffix
Args
if possible because it's not consistent with docs Then make use of namespaces as Zen of python says - I wonder how it would look if we could break it down into packages
Copy code
import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Let's say: I have
ServiceSourceConfiguration
Found another one with 84! 😄 ServiceSourceConfigurationCodeRepositoryCodeConfigurationCodeConfigurationValuesArgs
💥 1
r
FWIW, you don’t need to use the
Args
classes. They are provided as a convenience and an alternative to using keyword args. We added them recently as a user request so that args could be passed around separately from the resources. That being said, this is not about python but how the resources are structured in the encapsulating providers. Anyway, welcome to our world… let us know if you figure out how to do it in a way that you find more appealing and we’ll consider it 🙂
g
I took a lot of inspiration from CDK to me it seems they are on the right track
Instead of this
Copy code
authentication_configuration={
            "connection_arn": aws_apprunner_connection["example"]["arn"],
        }
I'd rather
Copy code
authentication_configuration=AuthenticationConfiguration(connection_arn='asdf')
In case this would be a conflict then use namespace -> sub-package
then user has choice whether to use full name from the parent or import as deeply as needed eg.
Copy code
from pulumi_aws.apprunner.service import AuthenticationConfiguration
r
I’d rather
Copy code
authentication_configuration=AuthenticationConfiguration(connection_arn='asdf')
This is how it currently works.
g
no, current Class name is
ServiceSourceConfigurationAuthenticationConfiguration
it should be at least 2 or 3 nested packages in order to prevent namespace conflicts. not just concacetnating names
On top of that word
Configuration
repeats in the name twice. In this class even three times!
Copy code
ServiceSourceConfigurationCodeRepositoryCodeConfigurationCodeConfiguration
names like this does not make anything easier to read, it's the exact opposite
r
It’s unlikely that we will take a massive breaking change like this, but you are welcome to open an issue and summarize your suggestion