dennisvang / tufup

Automated updates for stand-alone Python applications.
MIT License
99 stars 2 forks source link

Custom metadata should always return a dict #131

Closed dennisvang closed 8 months ago

dennisvang commented 8 months ago

problem

The current implementation of TargetMeta.custom and custom_internal returns either dict or None.

https://github.com/dennisvang/tufup/blob/735231c7dffce1aa46200725a2036087e5e6b458/src/tufup/common.py#L84-L94

There's no pressing reason for this, but it is highly inconvenient, because the user needs to check if the result is None, for example:

whatever = None
if my_meta.custom:  # <-- inconvenient
    whatever = my_meta.custom.get('whatever')

proposed solution

Always return a dict, so the user can simply do:

whatever = my_meta.custom.get('whatever')
dennisvang commented 8 months ago

Probably very few people, if any, are currently using the custom metadata option, as it is still relatively new.

Nevertheless, strictly speaking, this is a backward incompatible change for people explicitly relying on custom to return None.