Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecation warning when using entry points like dict in some python environments #473

Merged
merged 7 commits into from
Feb 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/ape/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,22 @@ def _suggest_cmd(usage_error):

@property
def commands(self) -> Dict:
group_name = "ape_cli_subcommands"
if not self._commands:
entry_points = metadata.entry_points() # type: ignore
try:
entry_points = metadata.entry_points(group=group_name) # type: ignore
except TypeError:
entry_points = metadata.entry_points()
entry_points = (
entry_points[group_name] if group_name in entry_points else [] # type: ignore
)

if "ape_cli_subcommands" not in entry_points:
if not entry_points:
raise Abort("Missing registered cli subcommands")

self._commands = {
clean_plugin_name(entry_point.name): entry_point.load
for entry_point in entry_points["ape_cli_subcommands"]
clean_plugin_name(entry_point.name): entry_point.load # type: ignore
antazoey marked this conversation as resolved.
Show resolved Hide resolved
for entry_point in entry_points
}

return self._commands
Expand Down