Commit df800b16 authored by Andrew Godwin's avatar Andrew Godwin
Browse files

Add clone() method to Field to get clean copies of it.

parent ab587fa5
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -240,6 +240,14 @@ class Field(object):
            keywords,
        )

    def clone(self):
        """
        Uses deconstruct() to clone a new copy of this Field.
        Will not preserve any class attachments/attribute names.
        """
        name, path, args, kwargs = self.deconstruct()
        return self.__class__(*args, **kwargs)

    def __eq__(self, other):
        # Needed for @total_ordering
        if isinstance(other, Field):