From 0b6b2e733a67df12d0720a1466829349c6504d19 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Mon, 26 Sep 2022 12:47:31 +0530 Subject: [PATCH] 1) Remove Python's 'Six' package completely. #5357 2) Replace deprecated @abstractproperty with @property, @abstractmethod. --- DEPENDENCIES | 27 +++++-------------- docs/en_US/release_notes_6_15.rst | 3 ++- requirements.txt | 1 - web/pgadmin/authenticate/internal.py | 4 +-- web/pgadmin/authenticate/mfa/registry.py | 10 +++---- web/pgadmin/browser/__init__.py | 10 +++---- web/pgadmin/browser/collection.py | 6 ++--- web/pgadmin/browser/server_groups/__init__.py | 4 +-- web/pgadmin/misc/bgprocess/processes.py | 3 ++- web/pgadmin/misc/cloud/azure/azure_cache.py | 5 +--- web/pgadmin/tools/sqleditor/command.py | 4 +-- web/pgadmin/utils/driver/abstract.py | 15 +++++------ .../tests/registry/__init__.py | 4 +-- .../tests/registry/registry.py | 7 ++--- web/pgadmin/utils/route.py | 4 +-- 15 files changed, 37 insertions(+), 70 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index bb96bf8fa..128a81551 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -12,9 +12,9 @@ Name Version ---- ------- ------- --- Python 3.6+ PSF https://www.python.org/ nw 0.50.2 MIT git://github.com/nwjs/npm-installer.git -axios 0.21.0 MIT https://github.com/axios/axios.git +axios 0.21.2 MIT https://github.com/axios/axios.git bootstrap 4.5.3 MIT git+https://github.com/twbs/bootstrap.git -follow-redirects 1.13.1 MIT git@github.com:follow-redirects/follow-redirects.git +follow-redirects 1.15.2 MIT git@github.com:follow-redirects/follow-redirects.git 5 dependencies listed. @@ -39,7 +39,6 @@ WTForms 3.0.1 passlib 1.7.4 BSD https://passlib.readthedocs.io pytz 2021.3 MIT http://pythonhosted.org/pytz simplejson 3.17.6 MIT License https://github.com/simplejson/simplejson -six 1.16.0 MIT https://github.com/benjaminp/six speaklater3 1.4 UNKNOWN https://github.com/ThomasWaldmann/speaklater sqlparse 0.4.2 BSD-3-Clause https://github.com/andialbrecht/sqlparse psutil 5.9.1 BSD https://github.com/giampaolo/psutil @@ -62,7 +61,7 @@ qrcode 7.3.1 Pillow 9.2.0 HPND https://python-pillow.org boto3 1.20.54 Apache License 2.0 https://github.com/boto/boto3 botocore 1.23.54 Apache License 2.0 https://github.com/boto/botocore -urllib3 1.26.11 MIT https://urllib3.readthedocs.io/ +urllib3 1.26.12 MIT https://urllib3.readthedocs.io/ Werkzeug 2.1.2 BSD-3-Clause https://palletsprojects.com/p/werkzeug/ azure-mgmt-rdbms 10.1.0 MIT License https://github.com/Azure/azure-sdk-for-python azure-mgmt-resource 21.0.0 MIT License https://github.com/Azure/azure-sdk-for-python @@ -72,7 +71,7 @@ azure-identity 1.9.0 NOTE: This report was generated using Python 3.10. Full information may not be shown for Python modules that are not required with this version. -45 dependencies listed. +44 dependencies listed. Javascript Dependencies ======================= @@ -157,7 +156,6 @@ Name Version @nodelib/fs.scandir 2.1.5 MIT https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.scandir @nodelib/fs.stat 2.0.5 MIT https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.stat @nodelib/fs.walk 1.2.8 MIT https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.walk -@popperjs/core 2.10.2 MIT https://github.com/popperjs/popper-core.git @projectstorm/geometry 6.6.1 MIT https://github.com/projectstorm/react-diagrams.git @projectstorm/react-canvas-core 6.6.1 MIT https://github.com/projectstorm/react-diagrams.git @projectstorm/react-diagrams 6.6.1 MIT https://github.com/projectstorm/react-diagrams.git @@ -169,7 +167,6 @@ Name Version @socket.io/base64-arraybuffer 1.0.2 MIT https://github.com/socketio/base64-arraybuffer @socket.io/component-emitter 3.0.0 MIT https://github.com/socketio/emitter.git @szhsin/react-menu 2.3.3 MIT https://github.com/szhsin/react-menu.git -@tippyjs/react 4.2.6 MIT git+https://github.com/atomiks/tippyjs-react.git @types/classnames 2.3.1 MIT Unknown @types/json-schema 7.0.9 MIT https://github.com/DefinitelyTyped/DefinitelyTyped.git @types/minimist 1.2.2 MIT https://github.com/DefinitelyTyped/DefinitelyTyped.git @@ -186,7 +183,6 @@ ajv 8.9.0 ajv 6.12.6 MIT https://github.com/ajv-validator/ajv.git ajv-errors 1.0.1 MIT git+https://github.com/epoberezkin/ajv-errors.git ajv-keywords 3.5.2 MIT git+https://github.com/epoberezkin/ajv-keywords.git -alertifyjs 1.7.1 MIT git@github.com:MohammadYounes/AlertifyJS.git alphanum-sort 1.0.2 MIT https://github.com/TrySound/alphanum-sort.git ansi-styles 3.2.1 MIT https://github.com/chalk/ansi-styles.git array-union 3.0.1 MIT https://github.com/sindresorhus/array-union.git @@ -201,12 +197,6 @@ babel-plugin-styled-components 1.13.3 babel-plugin-syntax-jsx 6.18.0 MIT https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-jsx babelify 10.0.0 MIT https://github.com/babel/babelify.git backbone 1.4.0 MIT https://github.com/jashkenas/backbone.git -backbone 1.2.3 MIT https://github.com/jashkenas/backbone.git -backbone 1.3.3 MIT https://github.com/jashkenas/backbone.git -backform 0.2.0 MIT https://github.com/AmiliaApp/backform -backgrid 0.3.8 MIT http://github.com/cloudflare/backgrid -backgrid-filter 0.3.7 MIT git://github.com/wyuenho/backgrid-text-cell.git -backgrid-select-all 0.3.5 MIT git://github.com/wyuenho/backgrid-select-all.git backo2 1.0.2 MIT https://github.com/mokesmokes/backo.git balanced-match 1.0.2 MIT git://github.com/juliangruber/balanced-match.git base64-arraybuffer 0.2.0 MIT https://github.com/niklasvh/base64-arraybuffer @@ -366,7 +356,6 @@ lodash.noop 2.3.0 lodash.support 2.3.0 MIT https://github.com/lodash/lodash-cli.git lodash.uniq 4.5.0 MIT https://github.com/lodash/lodash.git loose-envify 1.4.0 MIT git://github.com/zertosh/loose-envify.git -lunr 0.7.2 MIT https://github.com/olivernn/lunr.js.git make-dir 3.1.0 MIT https://github.com/sindresorhus/make-dir.git map-obj 4.3.0 MIT https://github.com/sindresorhus/map-obj.git map-obj 1.0.1 MIT https://github.com/sindresorhus/map-obj.git @@ -385,7 +374,7 @@ ml-array-rescale 1.3.6 ml-matrix 6.8.0 MIT https://github.com/mljs/matrix.git mobius1-selectr 2.4.13 MIT git+https://github.com/Mobius1/Selectr.git moment 2.29.4 MIT https://github.com/moment/moment.git -moment-timezone 0.5.34 MIT https://github.com/moment/moment-timezone.git +moment-timezone 0.5.37 MIT https://github.com/moment/moment-timezone.git ms 2.1.2 MIT https://github.com/zeit/ms.git nanoid 3.3.2 MIT https://github.com/ai/nanoid.git nanoid 3.2.0 MIT https://github.com/ai/nanoid.git @@ -464,7 +453,7 @@ react 17.0.2 react-aspen 1.2.0 MIT https://github.com/neeksandhu/react-aspen.git react-aspen 1.1.1 MIT https://github.com/neeksandhu/react-aspen.git react-checkbox-tree 1.7.2 MIT https://github.com/jakezatecky/react-checkbox-tree -react-data-grid 7.0.0-beta.12 MIT https://github.com/adazzle/react-data-grid.git +react-data-grid 7.0.0-beta.14 MIT https://github.com/adazzle/react-data-grid.git react-dom 16.14.0 MIT git+https://github.com/facebook/react.git react-dom 17.0.2 MIT https://github.com/facebook/react.git react-draggable 4.4.4 MIT https://github.com/react-grid-layout/react-draggable.git @@ -499,7 +488,6 @@ select2 4.0.13 shallowequal 1.1.0 MIT https://github.com/dashed/shallowequal.git shim-loader 1.0.1 MIT https://github.com/zinserjan/shim-loader slash 4.0.0 MIT https://github.com/sindresorhus/slash.git -slickgrid 2.3.16 MIT git+https://github.com/6pac/SlickGrid.git snapsvg-cjs 0.0.6 MIT git+https://github.com/geelen/Snap.svg-cjs.git socket.io-client 4.3.2 MIT https://github.com/socketio/socket.io-client.git socket.io-parser 4.1.1 MIT https://github.com/socketio/socket.io-parser.git @@ -521,7 +509,6 @@ text-segmentation 1.0.2 timsort 0.3.0 MIT https://github.com/mziccard/node-timsort.git tiny-emitter 2.1.0 MIT https://github.com/scottcorgan/tiny-emitter.git tiny-warning 1.0.3 MIT https://github.com/alexreardon/tiny-warning.git -tippy.js 6.3.5 MIT git+https://github.com/atomiks/tippyjs.git to-fast-properties 2.0.0 MIT https://github.com/sindresorhus/to-fast-properties.git to-regex-range 5.0.1 MIT https://github.com/micromatch/to-regex-range.git trim-newlines 4.0.2 MIT https://github.com/sindresorhus/trim-newlines.git @@ -620,5 +607,5 @@ tslib 2.4.0 tslib 2.3.0 0BSD https://github.com/Microsoft/tslib.git type-fest 1.4.0 (MIT OR CC0-1.0) https://github.com/sindresorhus/type-fest.git -540 dependencies listed. +528 dependencies listed. diff --git a/docs/en_US/release_notes_6_15.rst b/docs/en_US/release_notes_6_15.rst index 6523ef104..647a20f61 100644 --- a/docs/en_US/release_notes_6_15.rst +++ b/docs/en_US/release_notes_6_15.rst @@ -21,6 +21,7 @@ Housekeeping ************ | `Issue #5293 `_ - Ensure that the tooltips are consistent throughout the entire application. + | `Issue #5357 `_ - Remove Python's 'Six' package completely. Bug fixes ********* @@ -33,4 +34,4 @@ Bug fixes | `Issue #5261 `_ - Ensure that the search filter should be cleared when a new row is added to the user management. | `Issue #5262 `_ - Ensure that the user management dialog should not allow the same email addresses with different letter casings when creating users. | `Issue #5308 `_ - Ensure that the default value for a column should be used if it is made empty. - | `Issue #5368 `_ - Fixed the issue while downloading the file from file manager. \ No newline at end of file + | `Issue #5368 `_ - Fixed the issue while downloading the file from the file manager. diff --git a/requirements.txt b/requirements.txt index c42270821..c9673fab7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,7 +25,6 @@ WTForms==3.* passlib==1.* pytz==2021.* simplejson==3.* -six==1.* speaklater3==1.* sqlparse==0.* psutil==5.* diff --git a/web/pgadmin/authenticate/internal.py b/web/pgadmin/authenticate/internal.py index 64517cc10..abc94397f 100644 --- a/web/pgadmin/authenticate/internal.py +++ b/web/pgadmin/authenticate/internal.py @@ -9,7 +9,6 @@ """Implements Internal Authentication""" -import six from flask import current_app, flash from flask_security import login_user from abc import abstractmethod, abstractproperty @@ -21,8 +20,7 @@ from pgadmin.utils.validation_utils import validate_email from pgadmin.utils.constants import INTERNAL -@six.add_metaclass(AuthSourceRegistry) -class BaseAuthentication(object): +class BaseAuthentication(object, metaclass=AuthSourceRegistry): DEFAULT_MSG = { 'USER_DOES_NOT_EXIST': gettext('Incorrect username or password.'), diff --git a/web/pgadmin/authenticate/mfa/registry.py b/web/pgadmin/authenticate/mfa/registry.py index dae8c7fac..6195eb5ab 100644 --- a/web/pgadmin/authenticate/mfa/registry.py +++ b/web/pgadmin/authenticate/mfa/registry.py @@ -9,7 +9,6 @@ """External 2FA Authentication Registry.""" from abc import abstractmethod, abstractproperty -import six from typing import Union import flask @@ -50,8 +49,7 @@ MultiFactorAuthRegistry = create_registry_metaclass( ) -@six.add_metaclass(MultiFactorAuthRegistry) -class BaseMFAuth(): +class BaseMFAuth(metaclass=MultiFactorAuthRegistry): """ Base Multi-Factor Authentication (MFA) class @@ -60,7 +58,8 @@ class BaseMFAuth(): available as a MFA method. """ - @abstractproperty + @property + @abstractmethod def name(self) -> str: """ Represents the short name for the authentiation method. It can be used @@ -74,7 +73,8 @@ class BaseMFAuth(): """ pass - @abstractproperty + @property + @abstractmethod def label(self) -> str: """ Represents the user visible name for the authentiation method. It will diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py index c7a078d60..d5b9bc071 100644 --- a/web/pgadmin/browser/__init__.py +++ b/web/pgadmin/browser/__init__.py @@ -18,7 +18,6 @@ from smtplib import SMTPConnectError, SMTPResponseException, \ from socket import error as SOCKETErrorException from urllib.request import urlopen -import six import time from flask import current_app, render_template, url_for, make_response, \ flash, Response, request, after_this_request, redirect, session @@ -227,8 +226,7 @@ class BrowserModule(PgAdminModule): blueprint = BrowserModule(MODULE_NAME, __name__) -@six.add_metaclass(ABCMeta) -class BrowserPluginModule(PgAdminModule): +class BrowserPluginModule(PgAdminModule, metaclass=ABCMeta): """ Abstract base class for browser submodules. @@ -351,11 +349,13 @@ class BrowserPluginModule(PgAdminModule): """ return [] - @abstractproperty + @property + @abstractmethod def node_type(self): pass - @abstractproperty + @property + @abstractmethod def script_load(self): """ This property defines, when to load this script. diff --git a/web/pgadmin/browser/collection.py b/web/pgadmin/browser/collection.py index 5127d5615..e81205760 100644 --- a/web/pgadmin/browser/collection.py +++ b/web/pgadmin/browser/collection.py @@ -9,8 +9,7 @@ from abc import ABCMeta, abstractmethod -import six -from flask import url_for, render_template +from flask import render_template from flask_babel import gettext from pgadmin.browser import BrowserPluginModule from pgadmin.browser.utils import PGChildModule @@ -19,8 +18,7 @@ from pgadmin.utils.preferences import Preferences from pgadmin.utils.constants import PGADMIN_NODE -@six.add_metaclass(ABCMeta) -class CollectionNodeModule(PgAdminModule, PGChildModule): +class CollectionNodeModule(PgAdminModule, PGChildModule, metaclass=ABCMeta): """ Base class for collection node submodules. """ diff --git a/web/pgadmin/browser/server_groups/__init__.py b/web/pgadmin/browser/server_groups/__init__.py index 88368369e..3b90af31b 100644 --- a/web/pgadmin/browser/server_groups/__init__.py +++ b/web/pgadmin/browser/server_groups/__init__.py @@ -12,7 +12,6 @@ import simplejson as json from abc import ABCMeta, abstractmethod -import six from flask import request, jsonify, render_template from flask_babel import gettext from flask_security import current_user, login_required @@ -139,8 +138,7 @@ class ServerGroupMenuItem(MenuItem): super(ServerGroupMenuItem, self).__init__(**kwargs) -@six.add_metaclass(ABCMeta) -class ServerGroupPluginModule(BrowserPluginModule): +class ServerGroupPluginModule(BrowserPluginModule, metaclass=ABCMeta): """ Base class for server group plugins. """ diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py index 4627a5433..5d4f76702 100644 --- a/web/pgadmin/misc/bgprocess/processes.py +++ b/web/pgadmin/misc/bgprocess/processes.py @@ -56,7 +56,8 @@ def get_current_time(format='%Y-%m-%d %H:%M:%S.%f %z'): class IProcessDesc(object, metaclass=ABCMeta): - @abstractproperty + @property + @abstractmethod def message(self): pass diff --git a/web/pgadmin/misc/cloud/azure/azure_cache.py b/web/pgadmin/misc/cloud/azure/azure_cache.py index c8f3be253..e8bacea74 100644 --- a/web/pgadmin/misc/cloud/azure/azure_cache.py +++ b/web/pgadmin/misc/cloud/azure/azure_cache.py @@ -8,9 +8,6 @@ import sys from typing import TYPE_CHECKING import config - -import six - if TYPE_CHECKING: from typing import Any import msal_extensions @@ -132,7 +129,7 @@ def _get_persistence( ' the cache unencrypted' " instead of raising this exception." ) - six.raise_from(error, ex) + raise error return msal_extensions.FilePersistence(cache_file_path) raise NotImplementedError("A persistent cache is not " diff --git a/web/pgadmin/tools/sqleditor/command.py b/web/pgadmin/tools/sqleditor/command.py index 5f8218b30..9b80c0717 100644 --- a/web/pgadmin/tools/sqleditor/command.py +++ b/web/pgadmin/tools/sqleditor/command.py @@ -11,7 +11,6 @@ from abc import ABCMeta, abstractmethod from collections import OrderedDict -import six from flask import render_template from flask_babel import gettext from werkzeug.exceptions import InternalServerError @@ -76,8 +75,7 @@ class ObjectRegistry(ABCMeta): ) -@six.add_metaclass(ObjectRegistry) -class BaseCommand(object): +class BaseCommand(object, metaclass=ObjectRegistry): """ class BaseCommand diff --git a/web/pgadmin/utils/driver/abstract.py b/web/pgadmin/utils/driver/abstract.py index 2359233e4..d3d444d33 100644 --- a/web/pgadmin/utils/driver/abstract.py +++ b/web/pgadmin/utils/driver/abstract.py @@ -10,14 +10,10 @@ """Implement the Base class for Driver and Connection""" from abc import ABCMeta, abstractmethod, abstractproperty - -import six - from .registry import DriverRegistry -@six.add_metaclass(DriverRegistry) -class BaseDriver(object): +class BaseDriver(object, metaclass=DriverRegistry): """ class BaseDriver(object): @@ -50,11 +46,13 @@ class BaseDriver(object): configuration. """ - @abstractproperty + @property + @abstractmethod def version(cls): pass - @abstractproperty + @property + @abstractmethod def libpq_version(cls): pass @@ -71,8 +69,7 @@ class BaseDriver(object): pass -@six.add_metaclass(ABCMeta) -class BaseConnection(object): +class BaseConnection(object, metaclass=ABCMeta): """ class BaseConnection(object) diff --git a/web/pgadmin/utils/dynamic_registry/tests/registry/__init__.py b/web/pgadmin/utils/dynamic_registry/tests/registry/__init__.py index 02c89b61b..e96ec6253 100644 --- a/web/pgadmin/utils/dynamic_registry/tests/registry/__init__.py +++ b/web/pgadmin/utils/dynamic_registry/tests/registry/__init__.py @@ -6,7 +6,6 @@ # This software is released under the PostgreSQL Licence # ########################################################################## -import six from pgadmin.utils.dynamic_registry import create_registry_metaclass from .registry import TestModuleRegistry, TestNamedRegistry, TestNameBase from .test1 import TestModule1 @@ -86,8 +85,7 @@ def test_create_base_class(): 'RegistryWithBaseClass', __package__, decorate_as_module=False ) - @six.add_metaclass(RegistryWithBaseClass) - class TestBase(object): + class TestBase(object, metaclass=RegistryWithBaseClass): pass registry = RegistryWithBaseClass._registry diff --git a/web/pgadmin/utils/dynamic_registry/tests/registry/registry.py b/web/pgadmin/utils/dynamic_registry/tests/registry/registry.py index e623bbf73..796c29e3b 100644 --- a/web/pgadmin/utils/dynamic_registry/tests/registry/registry.py +++ b/web/pgadmin/utils/dynamic_registry/tests/registry/registry.py @@ -6,7 +6,6 @@ # This software is released under the PostgreSQL Licence # ########################################################################## -import six from pgadmin.utils.dynamic_registry import create_registry_metaclass @@ -20,13 +19,11 @@ TestNamedRegistry = create_registry_metaclass( ) -@six.add_metaclass(TestModuleRegistry) -class TestModuleBase(object): +class TestModuleBase(object, metaclass=TestModuleRegistry): pass -@six.add_metaclass(TestNamedRegistry) -class TestNameBase(object): +class TestNameBase(object, metaclass=TestNamedRegistry): pass diff --git a/web/pgadmin/utils/route.py b/web/pgadmin/utils/route.py index 09e50b066..6ece469d9 100644 --- a/web/pgadmin/utils/route.py +++ b/web/pgadmin/utils/route.py @@ -12,7 +12,6 @@ import traceback from abc import ABCMeta, abstractmethod from importlib import import_module -import six from werkzeug.utils import find_modules from pgadmin.utils import server_utils @@ -122,8 +121,7 @@ class TestsGeneratorRegistry(ABCMeta): traceback.print_exc(file=sys.stderr) -@six.add_metaclass(TestsGeneratorRegistry) -class BaseTestGenerator(unittest.TestCase): +class BaseTestGenerator(unittest.TestCase, metaclass=TestsGeneratorRegistry): # Defining abstract method which will override by individual testcase. def setUp(self):