Skip to content

Commit 3449291

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 7d4ce79 commit 3449291

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
@@ -1,7 +1,6 @@
11
import secrets
22
import uuid
33
import warnings
4-
from collections.abc import Callable
54

65
from django.conf import settings
76
from django.core.exceptions import ValidationError
@@ -338,7 +337,7 @@ def __init__(self, editable=False, max_length=128, factory=None, **kwargs):
338337
non-callable value for factory is not supported.
339338
"""
340339

341-
if factory is not None and not isinstance(factory, Callable):
340+
if factory is not None and not callable(factory):
342341
raise TypeError("'factory' should either be a callable or 'None'")
343342
self._factory = factory
344343

0 commit comments

Comments
 (0)