Skip to content
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

Minor cleanup of the code handling UrlsafeTokenField's factory argument #607

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading