Return all ParamArgKeys for item matching the specified high scope.
(item: nodes.Item, scope: Scope)
| 223 | |
| 224 | |
| 225 | def get_param_argkeys(item: nodes.Item, scope: Scope) -> Iterator[ParamArgKey]: |
| 226 | """Return all ParamArgKeys for item matching the specified high scope.""" |
| 227 | assert scope is not Scope.Function |
| 228 | |
| 229 | try: |
| 230 | callspec: CallSpec2 = item.callspec # type: ignore[attr-defined] |
| 231 | except AttributeError: |
| 232 | return |
| 233 | |
| 234 | item_cls = None |
| 235 | if scope is Scope.Session: |
| 236 | scoped_item_path = None |
| 237 | elif scope is Scope.Package: |
| 238 | # Package key = module's directory. |
| 239 | scoped_item_path = item.path.parent |
| 240 | elif scope is Scope.Module: |
| 241 | scoped_item_path = item.path |
| 242 | elif scope is Scope.Class: |
| 243 | scoped_item_path = item.path |
| 244 | item_cls = item.cls # type: ignore[attr-defined] |
| 245 | else: |
| 246 | assert_never(scope) |
| 247 | |
| 248 | for argname in callspec.indices: |
| 249 | if callspec._arg2scope[argname] != scope: |
| 250 | continue |
| 251 | param_index = callspec.indices[argname] |
| 252 | yield ParamArgKey(argname, param_index, scoped_item_path, item_cls) |
| 253 | |
| 254 | |
| 255 | def reorder_items(items: Sequence[nodes.Item]) -> list[nodes.Item]: |
no test coverage detected