Skip to content

Commit

Permalink
Improve naming for callable_has_argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallaecio committed May 3, 2023
1 parent 8875a2d commit f335491
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions web_poet/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions web_poet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f335491

Please sign in to comment.