From f335491a7d7114464c969f41dd107a3a63563f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Chaves?= Date: Wed, 3 May 2023 14:12:57 +0200 Subject: [PATCH] Improve naming for callable_has_argument --- web_poet/fields.py | 4 ++-- web_poet/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web_poet/fields.py b/web_poet/fields.py index 365eff13..04c45f9f 100644 --- a/web_poet/fields.py +++ b/web_poet/fields.py @@ -10,7 +10,7 @@ import attrs from itemadapter import ItemAdapter -from web_poet.utils import cached_method, callable_has_argument, ensure_awaitable +from web_poet.utils import cached_method, callable_has_parameter, ensure_awaitable _FIELDS_INFO_ATTRIBUTE_READ = "_web_poet_fields_info" _FIELDS_INFO_ATTRIBUTE_WRITE = "_web_poet_fields_info_temp" @@ -110,7 +110,7 @@ def __get__(self, instance, owner=None): processor_functions = [] processors: List[Tuple[Callable, bool]] = [] for processor_function in processor_functions: - takes_page = callable_has_argument(processor_function, "page") + takes_page = callable_has_parameter(processor_function, "page") processors.append((processor_function, takes_page)) method = self._processed(self.original_method, processors) if cached: diff --git a/web_poet/utils.py b/web_poet/utils.py index f017b37d..fa8ffa77 100644 --- a/web_poet/utils.py +++ b/web_poet/utils.py @@ -12,13 +12,13 @@ from url_matcher import Patterns -def callable_has_argument(obj, kwarg): +def callable_has_parameter(obj, name): try: sig = inspect.signature(obj) except ValueError: # built-in, e.g. int return False else: - return kwarg in sig.parameters + return name in sig.parameters def get_fq_class_name(cls: type) -> str: