I have a class
which is used to hold a bunch of python static methods which will return a string from an environment variable.
class GitLabCiEnv():
"""
Gitlab CI Environment variables.
"""
@staticmethod
def CHAT_CHANNEL() -> str:
"""
Source chat channel which triggered the ChatOps command.
Added in GitLab 10.6
Available in GitLab Runner all
"""
return os.environ["CHAT_CHANNEL"]
@staticmethod
def CHAT_INPUT() -> str:
"""
Additional arguments passed in the ChatOps command.
Added in GitLab 10.6
Available in GitLab Runner all
"""
return os.environ["CHAT_INPUT"]
With this class
I can just call GitLabCiEnv.CHAT_CHANNEL()
to get the value of the environment variable. The "ugly" is, that I have to use paranthesis for each those @staticmethod
.
What I would do is GitLabCiEnv.CHAT_CHANNEL
without paranthesis.
I do not want to instantiate an object of this class, there is, in my opinion no benefit of having an object. I tried different implementations, using class variables, but then each variable will be initialized if the class is imported, this is not what i want.
Maybe someone has a solution for me.
Thank you very much!