Skip to content

Commit ba20559

Browse files
authored
Merge pull request #34 from codablock/speedup_group_decorator
Move frame gathering into error code path
2 parents 4c370e3 + 93ac9fb commit ba20559

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

click_option_group/_decorators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ def group(self,
107107
if not issubclass(cls, OptionGroup):
108108
raise TypeError("'cls' must be a subclass of 'OptionGroup' class.")
109109

110-
frame = inspect.getouterframes(inspect.currentframe())[self._outer_frame_index]
111-
lineno = frame.lineno
112-
113110
def decorator(func):
114111
callback, params = get_callback_and_params(func)
115112

116113
if callback not in self._decorating_state:
114+
frame = inspect.getouterframes(inspect.currentframe())[self._outer_frame_index]
115+
lineno = frame.lineno
116+
117117
with_name = f' "{name}"' if name else ''
118118
warnings.warn((f'The empty option group{with_name} was found (line {lineno}) '
119119
f'for "{callback.__name__}". The group will not be added.'),

0 commit comments

Comments
 (0)