Raise ValueError if an unknown **kwarg is given

This commit is contained in:
Lonami Exo 2017-09-30 18:45:56 +02:00
parent f1bca0fd06
commit 76e5206acc

View File

@ -118,8 +118,9 @@ class TelegramBareClient:
# Used on connection - the user may modify these and reconnect # Used on connection - the user may modify these and reconnect
kwargs['app_version'] = kwargs.get('app_version', self.__version__) kwargs['app_version'] = kwargs.get('app_version', self.__version__)
for name, value in kwargs.items(): for name, value in kwargs.items():
if hasattr(self.session, name): if not hasattr(self.session, name):
setattr(self.session, name, value) raise ValueError('Unknown named parameter', name)
setattr(self.session, name, value)
# Despite the state of the real connection, keep track of whether # Despite the state of the real connection, keep track of whether
# the user has explicitly called .connect() or .disconnect() here. # the user has explicitly called .connect() or .disconnect() here.