Skip to content

Commit 6c5ed66

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 e34de65 commit 6c5ed66

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

model_utils/fields.py

+1-2
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
@@ -346,7 +345,7 @@ def __init__(self, editable=False, max_length=128, factory=None, **kwargs):
346345
non-callable value for factory is not supported.
347346
"""
348347

349-
if factory is not None and not isinstance(factory, Callable):
348+
if factory is not None and not callable(factory):
350349
raise TypeError("'factory' should either be a callable or 'None'")
351350
self._factory = factory
352351

0 commit comments

Comments
 (0)