foundertherapy / django-cryptographic-fields

A set of fields that wrap standard Django fields with encryption provided by the python cryptography library.
MIT License
29 stars 34 forks source link

Code Beautification #1

Open levigross opened 9 years ago

levigross commented 9 years ago

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.

JshWright commented 8 years ago

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)