I'd like to propose we switch a lot of the get_* methods to use properties instead. Since it's a property without a setter defined trying to set it will not work. In cases where we do need to be able to set it a method decorated with @<property>.setter can be declared allowing assignment.
This makes the code look and work more Pythonicly.
before
class GitVersion(Version):
"""
Versioning based on the output of `git describe`
"""
[..]
def get_version(self):
cmd = 'git describe'
if self.config['arguments']:
cmd += ' ' + self.config['arguments']
return oneshot(cmd)
version = GitVersion().get_version()
after
class GitVersion(Version):
"""
Versioning based on the output of `git describe`
"""
[..]
@property
def version(self):
cmd = 'git describe'
if self.config['arguments']:
cmd += ' ' + self.config['arguments']
return oneshot(cmd)
I'd like to propose we switch a lot of the
get_*
methods to use properties instead. Since it's a property without a setter defined trying to set it will not work. In cases where we do need to be able to set it a method decorated with@<property>.setter
can be declared allowing assignment.This makes the code look and work more Pythonicly.
before
after