D4Vinci/Scrapling · error · TypeError
Argument with type "{type(arg)}" is not accepted, please rea
Error message
Argument with type "{type(arg)}" is not accepted, please read the docs. What it means
find_all() received a positional argument of an unsupported type. Accepted types are str, list/tuple/set of strs, dict of str->str, re.Pattern, and zero-or-more-arg callables; anything else (int, float, None, bytes, a Selector object, a numpy array...) hits the final else branch and raises TypeError naming the offending type.
Source
Thrown at scrapling/parser.py:748
if not all([(isinstance(k, str) and isinstance(v, str)) for k, v in arg.items()]):
raise TypeError(
"Nested dictionaries are not accepted, only string keys and string values are accepted"
)
attributes.update(arg)
elif isinstance(arg, re_Pattern):
patterns.add(arg)
elif callable(arg):
if len(signature(arg).parameters) > 0:
functions.append(arg)
else:
raise TypeError(
"Callable filter function must have at least one argument to take `Selector` objects."
)
else:
raise TypeError(f'Argument with type "{type(arg)}" is not accepted, please read the docs.')
if not all([(isinstance(k, str) and isinstance(v, str)) for k, v in kwargs.items()]):
raise TypeError("Only string values are accepted for arguments")
for attribute_name, value in kwargs.items():
# Only replace names for kwargs, replacing them in dictionaries doesn't make sense
attribute_name = _whitelisted.get(attribute_name, attribute_name)
attributes[attribute_name] = value
# It's easier and faster to build a selector than traversing the tree
tags = tags or set("*")
for tag in tags:
selector = tag
for key, value in attributes.items():
value = value.replace('"', r"\"") # Escape double quotes in user input
# Not escaping anything with the key so the user can pass patterns like {'href*': '/p/'} or get errors :)
selector += '[{}="{}"]'.format(key, value)
if selector != "*":View on GitHub (pinned to 5d213a2d47)
Solutions
- Check the offending type shown in the message ("Argument with type \"{type}\"") and trace where that value came from.
- Guard upstream lookups: tag = page.css_first('a') and use tag.name rather than assuming a variable is a str.
- Decode bytes to str before passing: find_all(body.decode()).
- Filter Nones out of dynamic arg lists: [a for a in args if a is not None].
Example fix
# before
tag_name = page.css_first('a') # Selector or None
selector.find_all(tag_name) # TypeError
# after
tag_name = page.css_first('a').name if page.css_first('a') else '*'
selector.find_all(tag_name) Defensive patterns
Strategy: type-guard
Validate before calling
ACCEPTED = (str, list, tuple, set, dict, re.Pattern) args = [a for a in args if a is None and False or a is not None] args = [a for a in args if isinstance(a, ACCEPTED) or callable(a)]
Type guard
def is_find_all_arg(arg) -> bool:
import re
return (
arg is None
or isinstance(arg, (str, list, tuple, set, dict, re.Pattern))
or callable(arg)
) Prevention
- Guard upstream lookups so tag-name variables are never None or Selector objects.
- Decode bytes to str before using them as tag names.
When it happens
Trigger: find_all(1), find_all(None), find_all(b'div'), or passing a Selector/element object by mistake.
Common situations: A variable that was expected to be a tag name string but is None after a failed lookup earlier in the pipeline; passing bytes from a network layer without decoding.
Related errors
- Nested Iterables are not accepted, only iterables of tag nam
- Nested dictionaries are not accepted, only string keys and s
- Only string values are accepted for arguments
- Response meta should be dictionary but got {type(meta).__nam
- Invalid proxy string: {proxy_string}
AI-assisted analysis of D4Vinci/Scrapling@5d213a2d47 (2026-08-14).
Data as JSON: /api/errors/9afacf163dbb3773.
Report an issue: GitHub.