summaryrefslogtreecommitdiff
path: root/sphinx/config.py
diff options
context:
space:
mode:
authorDaniel Eades <danieleades@hotmail.com>2022-01-10 13:51:35 +0000
committerDaniel Eades <danieleades@hotmail.com>2022-01-10 13:51:35 +0000
commit61ff90460d61a33a9187006fd199424b23e9fbd2 (patch)
tree7fca648bd26f8665722a5c59f9c1f424c5b5275c /sphinx/config.py
parent72d352f64ec97c2b15173cc1a191c0e80bde9630 (diff)
downloadsphinx-git-61ff90460d61a33a9187006fd199424b23e9fbd2.tar.gz
use 'callable' to check if object is callable (B004)
Diffstat (limited to 'sphinx/config.py')
-rw-r--r--sphinx/config.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/sphinx/config.py b/sphinx/config.py
index 38ed1d388..9cce0cc41 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -206,7 +206,7 @@ class Config:
except ValueError as exc:
raise ValueError(__('invalid number %r for config value %r, ignoring') %
(value, name)) from exc
- elif hasattr(defvalue, '__call__'):
+ elif callable(defvalue):
return value
elif defvalue is not None and not isinstance(defvalue, str):
raise ValueError(__('cannot override config setting %r with unsupported '
@@ -257,7 +257,7 @@ class Config:
if name not in self.values:
raise AttributeError(__('No such config value: %s') % name)
default = self.values[name][0]
- if hasattr(default, '__call__'):
+ if callable(default):
return default(self)
return default
@@ -413,7 +413,7 @@ def check_confval_types(app: "Sphinx", config: Config) -> None:
for confval in config:
default, rebuild, annotations = config.values[confval.name]
- if hasattr(default, '__call__'):
+ if callable(default):
default = default(config) # evaluate default value
if default is None and not annotations:
continue # neither inferable nor expliclitly annotated types