Skip to content

Commit b2337a6

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#14928
1 parent 7fd664f commit b2337a6

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
@@ -2,7 +2,6 @@
22

33
import secrets
44
import uuid
5-
from collections.abc import Callable
65

76
from django.conf import settings
87
from django.core.exceptions import ValidationError
@@ -329,7 +328,7 @@ def __init__(self, editable=False, max_length=128, factory=None, **kwargs):
329328
non-callable value for factory is not supported.
330329
"""
331330

332-
if factory is not None and not isinstance(factory, Callable):
331+
if factory is not None and not callable(factory):
333332
raise TypeError("'factory' should either be a callable or 'None'")
334333
self._factory = factory
335334

0 commit comments

Comments
 (0)