{"record":{"id":"9afacf163dbb3773","repo":"D4Vinci/Scrapling","slug":"argument-with-type-type-arg-is-not-accepted","errorCode":null,"errorMessage":"Argument with type \"{type(arg)}\" is not accepted, please read the docs.","messagePattern":"Argument with type \"(.+?)\" is not accepted, please read the docs\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"scrapling/parser.py","lineNumber":748,"sourceCode":"                if not all([(isinstance(k, str) and isinstance(v, str)) for k, v in arg.items()]):\n                    raise TypeError(\n                        \"Nested dictionaries are not accepted, only string keys and string values are accepted\"\n                    )\n                attributes.update(arg)\n\n            elif isinstance(arg, re_Pattern):\n                patterns.add(arg)\n\n            elif callable(arg):\n                if len(signature(arg).parameters) > 0:\n                    functions.append(arg)\n                else:\n                    raise TypeError(\n                        \"Callable filter function must have at least one argument to take `Selector` objects.\"\n                    )\n\n            else:\n                raise TypeError(f'Argument with type \"{type(arg)}\" is not accepted, please read the docs.')\n\n        if not all([(isinstance(k, str) and isinstance(v, str)) for k, v in kwargs.items()]):\n            raise TypeError(\"Only string values are accepted for arguments\")\n\n        for attribute_name, value in kwargs.items():\n            # Only replace names for kwargs, replacing them in dictionaries doesn't make sense\n            attribute_name = _whitelisted.get(attribute_name, attribute_name)\n            attributes[attribute_name] = value\n\n        # It's easier and faster to build a selector than traversing the tree\n        tags = tags or set(\"*\")\n        for tag in tags:\n            selector = tag\n            for key, value in attributes.items():\n                value = value.replace('\"', r\"\\\"\")  # Escape double quotes in user input\n                # Not escaping anything with the key so the user can pass patterns like {'href*': '/p/'} or get errors :)\n                selector += '[{}=\"{}\"]'.format(key, value)\n            if selector != \"*\":","sourceCodeStart":730,"sourceCodeEnd":766,"githubUrl":"https://github.com/D4Vinci/Scrapling/blob/5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f/scrapling/parser.py#L730-L766","documentation":"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.","triggerScenarios":"find_all(1), find_all(None), find_all(b'div'), or passing a Selector/element object by mistake.","commonSituations":"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.","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]."],"exampleFix":"# before\ntag_name = page.css_first('a')  # Selector or None\nselector.find_all(tag_name)  # TypeError\n\n# after\ntag_name = page.css_first('a').name if page.css_first('a') else '*'\nselector.find_all(tag_name)","handlingStrategy":"type-guard","validationCode":"ACCEPTED = (str, list, tuple, set, dict, re.Pattern)\nargs = [a for a in args if a is None and False or a is not None]\nargs = [a for a in args if isinstance(a, ACCEPTED) or callable(a)]","typeGuard":"def is_find_all_arg(arg) -> bool:\n    import re\n    return (\n        arg is None\n        or isinstance(arg, (str, list, tuple, set, dict, re.Pattern))\n        or callable(arg)\n    )","tryCatchPattern":null,"preventionTips":["Guard upstream lookups so tag-name variables are never None or Selector objects.","Decode bytes to str before using them as tag names."],"tags":["find-all","validation","type-error"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}