From a19734b84765f982119bdae9247873de846f58cb Mon Sep 17 00:00:00 2001 From: dgw Date: Sun, 12 Feb 2023 17:49:56 -0600 Subject: [PATCH] py, build: drop `py` plugin from core & require external package End of support for Python 2.7 on Google App Engine, in January 2024, approaches. Dropping this plugin from core now will let us make the transition to a new backend easier, without having to fit it into Sopel's release cadence. Marked the requirement with a TODO for 8.1, when it should become an optional manually-installed plugin like the others that have been packageized (ipython, spellcheck, etc.). --- pyproject.toml | 1 + sopel/modules/py.py | 65 ---------------------- test/vcr/modules/py/test_example_py_0.yaml | 23 -------- 3 files changed, 1 insertion(+), 88 deletions(-) delete mode 100644 sopel/modules/py.py delete mode 100644 test/vcr/modules/py/test_example_py_0.yaml diff --git a/pyproject.toml b/pyproject.toml index 1cd12796b7..e8b34d2a88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ dependencies = [ "importlib_metadata>=3.6", "packaging", "sopel-help>=0.4.0", + "sopel-py>=1.0.1", # TODO: drop for 8.1 ] [project.urls] diff --git a/sopel/modules/py.py b/sopel/modules/py.py deleted file mode 100644 index 4f134323ce..0000000000 --- a/sopel/modules/py.py +++ /dev/null @@ -1,65 +0,0 @@ -""" -py.py - Sopel Python Eval Plugin -Copyright 2008, Sean B. Palmer, inamidst.com -Licensed under the Eiffel Forum License 2. - -https://sopel.chat -""" -from __future__ import annotations - -from requests import get - -from sopel import plugin -from sopel.config import types -from sopel.tools.web import quote - - -class PySection(types.StaticSection): - oblique_instance = types.ValidatedAttribute( - 'oblique_instance', - default='https://oblique.sopel.chat/') - """The Oblique instance to use when evaluating Python expressions""" - - -def configure(config): - """ - | name | example | purpose | - | ---- | ------- | ------- | - | oblique_instance | https://oblique.sopel.chat/ | The Oblique instance to use when evaluating Python expressions (see ) | - """ - config.define_section('py', PySection) - config.py.configure_setting( - 'oblique_instance', - 'Enter the base URL of a custom Oblique instance (optional): ' - ) - - -def setup(bot): - bot.config.define_section('py', PySection) - - if not any( - bot.config.py.oblique_instance.startswith(prot) - for prot in ['http://', 'https://'] - ): - raise ValueError('Oblique instance URL must start with a protocol.') - - if not bot.config.py.oblique_instance.endswith('/'): - bot.config.py.oblique_instance += '/' - - -@plugin.command('py') -@plugin.output_prefix('[py] ') -@plugin.example('.py len([1,2,3])', '3', online=True, vcr=True) -def py(bot, trigger): - """Evaluate a Python expression.""" - query = trigger.group(2) - if not query: - bot.reply('What expression do you want me to evaluate?') - return - - uri = bot.config.py.oblique_instance + 'py/' - answer = get(uri + quote(query)).content.decode('utf-8') - if answer: - bot.say(answer) - else: - bot.reply('Sorry, no result.') diff --git a/test/vcr/modules/py/test_example_py_0.yaml b/test/vcr/modules/py/test_example_py_0.yaml deleted file mode 100644 index b41cf7a754..0000000000 --- a/test/vcr/modules/py/test_example_py_0.yaml +++ /dev/null @@ -1,23 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate'] - Connection: [keep-alive] - User-Agent: [python-requests/2.24.0] - method: GET - uri: https://oblique.sopel.chat/py/len%28%5B1%2C2%2C3%5D%29 - response: - body: {string: '3 - -'} - headers: - Cache-Control: [no-cache] - Content-Length: ['2'] - Content-Type: [text/plain] - Date: ['Fri, 09 Oct 2020 04:40:29 GMT'] - Server: [Google Frontend] - X-Cloud-Trace-Context: [ca53ebf0dbb861ffcceed76af746c923;o=1] - status: {code: 200, message: OK} -version: 1