MCPcopy
hub / github.com/scrapy/scrapy / iter_spider_classes

Function iter_spider_classes

scrapy/utils/spider.py:50–61  ·  view source on GitHub ↗

Return an iterator over all spider classes defined in the given module that can be instantiated (i.e. which have name)

(module: ModuleType)

Source from the content-addressed store, hash-verified

48
49
50def iter_spider_classes(module: ModuleType) -> Iterable[type[Spider]]:
51 """Return an iterator over all spider classes defined in the given module
52 that can be instantiated (i.e. which have name)
53 """
54 for obj in vars(module).values():
55 if (
56 inspect.isclass(obj)
57 and issubclass(obj, Spider)
58 and obj.__module__ == module.__name__
59 and getattr(obj, "name", None)
60 ):
61 yield obj
62
63
64@overload

Callers 3

_load_spidersMethod · 0.90
runMethod · 0.90
test_iter_spider_classesFunction · 0.90

Calls 1

valuesMethod · 0.80

Tested by 1

test_iter_spider_classesFunction · 0.72