MCPcopy
hub / github.com/scrapy/scrapy / extract_contracts

Method extract_contracts

scrapy/contracts/__init__.py:108–123  ·  view source on GitHub ↗
(self, method: Callable[..., Any])

Source from the content-addressed store, hash-verified

106 return methods
107
108 def extract_contracts(self, method: Callable[..., Any]) -> list[Contract]:
109 contracts: list[Contract] = []
110 assert method.__doc__ is not None
111 for line_ in method.__doc__.split("\n"):
112 line = line_.strip()
113
114 if line.startswith("@"):
115 m = re.match(r"@(\w+)\s*(.*)", line)
116 if m is None:
117 continue
118 name, args = m.groups()
119 args = re.split(r"\s+", args)
120
121 contracts.append(self.contracts[name](method, *args))
122
123 return contracts
124
125 def from_spider(self, spider: Spider, results: TestResult) -> list[Request | None]:
126 requests: list[Request | None] = []

Callers 4

from_methodMethod · 0.95
test_contractsMethod · 0.80
test_cb_kwargsMethod · 0.80
test_metaMethod · 0.80

Calls

no outgoing calls

Tested by 3

test_contractsMethod · 0.64
test_cb_kwargsMethod · 0.64
test_metaMethod · 0.64