Skip to content

Commit

Permalink
Merge pull request #607 from ProtixIT/cleanup-factory
Browse files Browse the repository at this point in the history
Minor cleanup of the code handling `UrlsafeTokenField`'s `factory` argument
  • Loading branch information
foarsitter authored Apr 3, 2024
2 parents 9e71a46 + 6c5ed66 commit 89653b2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions model_utils/fields.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import secrets
import uuid
import warnings
from collections.abc import Callable

from django.conf import settings
from django.core.exceptions import ValidationError
Expand Down Expand Up @@ -346,8 +345,8 @@ def __init__(self, editable=False, max_length=128, factory=None, **kwargs):
non-callable value for factory is not supported.
"""

if factory is not None and not isinstance(factory, Callable):
raise TypeError("'factory' should either be a callable not 'None'")
if factory is not None and not callable(factory):
raise TypeError("'factory' should either be a callable or 'None'")
self._factory = factory

kwargs.pop('default', None) # passing default value has not effect.
Expand Down

0 comments on commit 89653b2

Please sign in to comment.