From a9b3e6dc422f1bb66984b87c1620831bec6f9f9f Mon Sep 17 00:00:00 2001 From: Gunther Cox Date: Thu, 25 Jan 2018 22:53:01 -0500 Subject: [PATCH] Remove features marked as deprecated --- chatterbot/chatterbot.py | 21 --------------- chatterbot/logic/multi_adapter.py | 11 -------- .../logic_adapter_tests/test_multi_adapter.py | 6 ++--- tests/test_chatbot.py | 26 ------------------- 4 files changed, 3 insertions(+), 61 deletions(-) diff --git a/chatterbot/chatterbot.py b/chatterbot/chatterbot.py index 46922f9aa..c12bc7563 100644 --- a/chatterbot/chatterbot.py +++ b/chatterbot/chatterbot.py @@ -168,24 +168,3 @@ def train(self): Proxy method to the chat bot's trainer class. """ return self.trainer.train - - @classmethod - def from_config(cls, config_file_path): - """ - Create a new ChatBot instance from a JSON config file. - """ - import json - import warnings - - warnings.warn( - 'The from_config method is deprecated and ' - 'will be removed in ChatterBot version 0.8.', - DeprecationWarning - ) - - with open(config_file_path, 'r') as config_file: - data = json.load(config_file) - - name = data.pop('name') - - return ChatBot(name, **data) diff --git a/chatterbot/logic/multi_adapter.py b/chatterbot/logic/multi_adapter.py index 2c5b9be7b..17e91f4d1 100644 --- a/chatterbot/logic/multi_adapter.py +++ b/chatterbot/logic/multi_adapter.py @@ -1,5 +1,4 @@ from __future__ import unicode_literals -import warnings from collections import Counter from chatterbot import utils from .logic_adapter import LogicAdapter @@ -50,16 +49,6 @@ def process(self, statement): if adapter.can_process(statement): output = adapter.process(statement) - - if type(output) == tuple: - warnings.warn( - '{} returned two values when just a Statement object was expected. ' - 'You should update your logic adapter to return just the Statement object. ' - 'Make sure that statement.confidence is being set.'.format(adapter.class_name), - DeprecationWarning - ) - output = output[1] - results.append((output.confidence, output, )) self.logger.info( diff --git a/tests/logic_adapter_tests/test_multi_adapter.py b/tests/logic_adapter_tests/test_multi_adapter.py index 4480cadf9..e2aaa0621 100644 --- a/tests/logic_adapter_tests/test_multi_adapter.py +++ b/tests/logic_adapter_tests/test_multi_adapter.py @@ -9,7 +9,7 @@ class TestAdapterA(LogicAdapter): def process(self, statement): response = Statement('Good morning.') response.confidence = 0.2 - return response.confidence, response + return response class TestAdapterB(LogicAdapter): @@ -17,7 +17,7 @@ class TestAdapterB(LogicAdapter): def process(self, statement): response = Statement('Good morning.') response.confidence = 0.5 - return response.confidence, response + return response class TestAdapterC(LogicAdapter): @@ -25,7 +25,7 @@ class TestAdapterC(LogicAdapter): def process(self, statement): response = Statement('Good night.') response.confidence = 0.7 - return response.confidence, response + return response class MultiLogicAdapterTestCase(ChatBotTestCase): diff --git a/tests/test_chatbot.py b/tests/test_chatbot.py index 69bece366..d7c5bec46 100644 --- a/tests/test_chatbot.py +++ b/tests/test_chatbot.py @@ -165,29 +165,3 @@ def test_update_does_not_add_new_statement(self): self.assertEqual(response, self.test_statement.text) self.assertIsNone(statement_found) - - -class ChatBotConfigFileTestCase(ChatBotTestCase): - - def setUp(self): - super(ChatBotConfigFileTestCase, self).setUp() - import json - self.config_file_path = './test-config.json' - self.data = self.get_kwargs() - self.data['name'] = 'Config Test' - - with open(self.config_file_path, 'w+') as config_file: - json.dump(self.data, config_file) - - def tearDown(self): - super(ChatBotConfigFileTestCase, self).tearDown() - import os - - if os.path.exists(self.config_file_path): - os.remove(self.config_file_path) - - def test_read_from_config_file(self): - from chatterbot import ChatBot - self.chatbot = ChatBot.from_config(self.config_file_path) - - self.assertEqual(self.chatbot.name, self.data['name'])