Skip to content

Commit

Permalink
Use callable() builtin function over isinstance(..., Callable)
Browse files Browse the repository at this point in the history
This is slightly more compact, but the main motivation is to work
around the following mypy bug:

python/mypy#3060
  • Loading branch information
cr313 committed Mar 26, 2024
1 parent f689d65 commit 9879b74
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 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,7 +345,7 @@ 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):
if factory is not None and not callable(factory):
raise TypeError("'factory' should either be a callable or 'None'")
self._factory = factory

Expand Down

0 comments on commit 9879b74

Please sign in to comment.