foundertherapy/django-cryptographic-fields

Code Beautification

Opened this issue · 1 comments

This section of the EncryptedMixin

        if not self.max_length:
            self.max_length = 10
        self.unencrypted_max_length = self.max_length
        self.max_length = calc_encrypted_length(self.unencrypted_max_length)

Can be written better

        self.unencrypted_max_length = self.max_length or 10
        self.max_length = calc_encrypted_length(self.unencrypted_max_length)

This saves you the if statement and reassignment.

Really, since unencrypted_max_length isn't used anywhere else, the whole thing could be:

    self.max_length = calc_encrypted_length(self.max_length or 10)