Skip to content

Commit cd4aded

Browse files
committed
Reduced method complexity
1 parent 284e606 commit cd4aded

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

telegram/ext/handler.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ def handle_update(self, update, dispatcher):
117117
"""
118118
raise NotImplementedError
119119

120+
def __warn_autowire(self):
121+
""" Warn if the user has set any `pass_*` flags to True in addition to `autowire` """
122+
for flag in self.__get_available_pass_flags():
123+
to_pass = bool(getattr(self, flag))
124+
if to_pass is True:
125+
warnings.warn('If `autowire` is set to `True`, it is unnecessary '
126+
'to provide the `{}` flag.'.format(flag))
127+
120128
def __get_available_pass_flags(self):
121129
"""
122130
Used to provide warnings if the user decides to use `autowire` in conjunction with
@@ -143,6 +151,7 @@ def set_autowired_flags(self, passable={'update_queue', 'job_queue', 'user_data'
143151

144152
if not self.autowire:
145153
raise ValueError("This handler is not autowired.")
154+
self.__warn_autowire()
146155

147156
if self._autowire_initialized:
148157
# In case that users decide to change their callback signatures at runtime, give the
@@ -167,13 +176,6 @@ def should_pass_obj(name):
167176
return False
168177
return is_requested
169178

170-
# Check whether the user has set any `pass_*` flag to True in addition to `autowire`
171-
for flag in self.__get_available_pass_flags():
172-
to_pass = bool(getattr(self, flag))
173-
if to_pass is True:
174-
warnings.warn('If `autowire` is set to `True`, it is unnecessary '
175-
'to provide the `{}` flag.'.format(flag))
176-
177179
if should_pass_obj('update_queue'):
178180
self.pass_update_queue = True
179181
if should_pass_obj('job_queue'):

0 commit comments

Comments
 (0)