Allow accessing `__getiitem__` of allow-listed instances unless it was not modified.
(self, value, item)
| 308 | return False |
| 309 | |
| 310 | def can_get_item(self, value, item): |
| 311 | """Allow accessing `__getiitem__` of allow-listed instances unless it was not modified.""" |
| 312 | allowed_getitem_external = _coerce_path_to_tuples(self.allowed_getitem_external) |
| 313 | if self.allow_getitem_on_types: |
| 314 | # e.g. Union[str, int] or Literal[True, 1] |
| 315 | if isinstance(value, (typing._SpecialForm, typing._BaseGenericAlias)): |
| 316 | return True |
| 317 | # PEP 560 e.g. list[str] |
| 318 | if isinstance(value, type) and hasattr(value, "__class_getitem__"): |
| 319 | return True |
| 320 | return _has_original_dunder( |
| 321 | value, |
| 322 | allowed_types=self.allowed_getitem, |
| 323 | allowed_methods=self._getitem_methods, |
| 324 | allowed_external=allowed_getitem_external, |
| 325 | method_name="__getitem__", |
| 326 | ) |
| 327 | |
| 328 | def can_operate(self, dunders: tuple[str, ...], a, b=None): |
| 329 | allowed_operations_external = _coerce_path_to_tuples( |
no test coverage detected