diffsync
diffsync copied to clipboard
Empty DiffSync instance evaluates as false
Environment
- DiffSync version: 1.3.0
- Python version: 3.6
Observed Behavior
When using diffsync within Nautobot-plugin-ssot, it would be nice to allow the Destination (Target) to have no data.
An empty DiffSync() evaluates to False. This causes a failure to proceed to the Diff.
the base DiffSync class has a len() method, an object’s default bool() casting must use that to determine whether it evaluates as truthy:
diffsync = DiffSync() bool(diffsync) False diffsync.add(DiffSyncModel()) bool(diffsync) True
Expected Behavior
diffsync proceeds to diff and then syncs data to the Destination (Target).
Workaround is to check explicitly is not None - see https://github.com/nautobot/nautobot-plugin-ssot/pull/18
Having thought about this a little before I merge my fix PR into next-2.0 - I actually consider this the more intuitive behavior as opposed to always returning True. I think the workaround specified in the comment above to me is very acceptable. Opinions on closing without a change?
See above comment.