(self)
| 598 | self._loaded_plugin_commands = False |
| 599 | |
| 600 | def _load_plugin_commands(self) -> None: |
| 601 | if self._loaded_plugin_commands: |
| 602 | return |
| 603 | |
| 604 | if sys.version_info >= (3, 10): |
| 605 | from importlib import metadata |
| 606 | else: |
| 607 | # Use a backport on Python < 3.10. We technically have |
| 608 | # importlib.metadata on 3.8+, but the API changed in 3.10, |
| 609 | # so use the backport for consistency. |
| 610 | import importlib_metadata as metadata # pyright: ignore |
| 611 | |
| 612 | for ep in metadata.entry_points(group="flask.commands"): |
| 613 | self.add_command(ep.load(), ep.name) |
| 614 | |
| 615 | self._loaded_plugin_commands = True |
| 616 | |
| 617 | def get_command(self, ctx: click.Context, name: str) -> click.Command | None: |
| 618 | self._load_plugin_commands() |
no test coverage detected