python-powerdns icon indicating copy to clipboard operation
python-powerdns copied to clipboard

Default return value of get_record

Open jschewebbn opened this issue 4 years ago • 3 comments

The default return value of get_record should probably be None. Instead of "" at https://github.com/outini/python-powerdns/blob/master/powerdns/interface.py#L244 this should be None. Then one can easily check if there is a valid return value.

jschewebbn avatar May 25 '21 15:05 jschewebbn

hello,

The method get_record returns a list instance in any case not to have inconsistent return statements. I usually return None if the method is supposed to return a single instance of an object.

In this case, an empty list still allows one to easily know if records have been found by doing a simple test on the list instance, which will return False if empty.

if not zone.get_record("nonexistent"):
    print("no record have been found")

Did you have an issue with that ?

Regards

outini avatar Jun 15 '21 12:06 outini

I see that get_record now has a a list as a default value, previously it did not. suggest_zone has a default value of the empty string instead of None, see https://github.com/outini/python-powerdns/blob/master/powerdns/interface.py#L248

jschewebbn avatar Jun 15 '21 12:06 jschewebbn

Ah this is a mistake, thank for pointing that out ! I'll fix it quickly

On Tue, Jun 15, 2021, 14:48 Jon Schewe @.***> wrote:

I see that get_record now has a a list as a default value, previously it did not. suggest_zone has a default value of the empty string instead of None, see https://github.com/outini/python-powerdns/blob/master/powerdns/interface.py#L248

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/outini/python-powerdns/issues/10#issuecomment-861469005, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGBX24MZIRSZ22Y2O5DLDLTS5DZ7ANCNFSM45PVURDQ .

outini avatar Jun 15 '21 16:06 outini