Skip to content

Code Beautification #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
levigross opened this issue May 11, 2015 · 1 comment
Open

Code Beautification #1

levigross opened this issue May 11, 2015 · 1 comment
Assignees

Comments

@levigross
Copy link

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
Copy link
Contributor

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)

octaflop pushed a commit to octaflop/django-cryptographic-fields that referenced this issue Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants