Skip to content

Empty DiffSync instance evaluates as false #84

Closed

Description

@smk4664

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).

Activity

  1. glennmatthews commented on Dec 16, 2021

    @glennmatthews
    Collaborator

    Workaround is to check explicitly is not None - see nautobot/nautobot-app-ssot#18

  2. changed the title [-]Allow Empty Destination in diffsync.[/-] [+]Empty DiffSync instance evaluates as false[/+] on Dec 16, 2021
  3. self-assigned this
    on Jun 29, 2022
  4. added this to the 2.0.0 milestone on Jun 29, 2022
  5. added
    status: acceptedThis issue has been accepted by the maintainers team for implementation
    on Feb 27, 2023
  6. Kircheneer commented on Aug 18, 2023

    @Kircheneer
    Contributor

    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?

  7. Kircheneer commented on Feb 15, 2024

    @Kircheneer
    Contributor

    See above comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted by the maintainers team for implementationtype: bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions