| 504 | |
| 505 | |
| 506 | class MagicMethodCompletion(BaseCompletionType): |
| 507 | def matches( |
| 508 | self, |
| 509 | cursor_offset: int, |
| 510 | line: str, |
| 511 | *, |
| 512 | current_block: str | None = None, |
| 513 | complete_magic_methods: bool | None = None, |
| 514 | **kwargs: Any, |
| 515 | ) -> set[str] | None: |
| 516 | if ( |
| 517 | current_block is None |
| 518 | or complete_magic_methods is None |
| 519 | or not complete_magic_methods |
| 520 | ): |
| 521 | return None |
| 522 | |
| 523 | r = self.locate(cursor_offset, line) |
| 524 | if r is None: |
| 525 | return None |
| 526 | if "class" not in current_block: |
| 527 | return None |
| 528 | return {name for name in MAGIC_METHODS if name.startswith(r.word)} |
| 529 | |
| 530 | def locate(self, cursor_offset: int, line: str) -> LinePart | None: |
| 531 | return lineparts.current_method_definition_name(cursor_offset, line) |
| 532 | |
| 533 | |
| 534 | class GlobalCompletion(BaseCompletionType): |
no outgoing calls
no test coverage detected