Updated: [rhinstaller/blivet/pulls/268 master] Add a class constructor for namedtuples with default values

vpodzime installerbot-noreply at redhat.com
Tue Nov 3 18:09:46 UTC 2015


namedtuple classes are great as pure data objects one can store things in and
then access them really easily. The problem is that if a new field is added to a
namedtuple, all places creating instances of it has to be modified to provide a
value for that new field. The default_namedtuple class constructor implemented
in this commit constructs namedtuples with default values for (some) fields and
fields without any value passed defaulting to None.

Such default namedtuple classes are still great for storing data and
e.g. passing data to functions/methods grouped into a few objects (like
DeviceInfo, FormatInfo,...) passed as arguments, but allow us to add extra
fields in the future (e.g. a new device attribute to DeviceInfo) without
breaking the API.
-- 
To view this pull request on github, visit https://github.com/rhinstaller/blivet/pull/268


More information about the anaconda-patches mailing list