Skip to content

Commit a60d2e0

Browse files
committed
Use callable() builtin function over isinstance(..., Callable)
This is slightly more compact, but the main motivation is to work around the following mypy bug: python/mypy#3060
1 parent 35b4922 commit a60d2e0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

model_utils/fields.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import secrets
44
import uuid
55
import warnings
6-
from collections.abc import Callable
76

87
from django.conf import settings
98
from django.core.exceptions import ValidationError
@@ -340,7 +339,7 @@ def __init__(self, editable=False, max_length=128, factory=None, **kwargs):
340339
non-callable value for factory is not supported.
341340
"""
342341

343-
if factory is not None and not isinstance(factory, Callable):
342+
if factory is not None and not callable(factory):
344343
raise TypeError("'factory' should either be a callable or 'None'")
345344
self._factory = factory
346345

0 commit comments

Comments
 (0)