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

⚡️ Speed up method Context.with_resource by 5% #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions src/click/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,19 @@ def get_parameter_source(self, name: str) -> ParameterSource | None:
"""
return self._parameter_source.get(name)

def _get_default_map(self, default_map, info_name, parent):
if default_map is None and info_name is not None and parent is not None and parent.default_map is not None:
return parent.default_map.get(info_name)
return default_map

def _get_auto_envvar_prefix(self, auto_envvar_prefix, parent, info_name):
if auto_envvar_prefix is None:
if parent is not None and parent.auto_envvar_prefix is not None and info_name is not None:
return f"{parent.auto_envvar_prefix}_{info_name.upper()}".replace("-", "_")
else:
return auto_envvar_prefix.upper().replace("-", "_")
return None


class Command:
"""Commands are the basic building block of command line interfaces in
Expand Down