From 272270521520c63bcbe5db3d1194febd36799a74 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sat, 6 Jan 2024 19:45:19 -0800 Subject: [PATCH 01/24] Remove pkg_resources in favor of importlib --- src/ofxstatement/plugin.py | 18 ++++++++---------- src/ofxstatement/tool.py | 5 ++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index 6c65459..611308f 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -4,21 +4,19 @@ """ from typing import List, Tuple, Type from collections.abc import MutableMapping -import pkg_resources +from importlib.metadata import entry_points from ofxstatement.ui import UI from ofxstatement.parser import AbstractStatementParser - def get_plugin(name: str, ui: UI, settings: MutableMapping) -> "Plugin": - plugins = list(pkg_resources.iter_entry_points("ofxstatement", name)) - if not plugins: + if not entry_points(group=name): raise PluginNotRegistered(name) - if len(plugins) > 1: + if len(entry_points(group=name)) > 1: raise PluginNameConflict(plugins) - pcls = plugins[0].load() - plugin = pcls(ui, settings) - return plugin + pcls = entry_points(group=name).attr + plugin = pcls.load() + return plugin(ui,settings) def list_plugins() -> List[Tuple[str, Type["Plugin"]]]: @@ -26,8 +24,8 @@ def list_plugins() -> List[Tuple[str, Type["Plugin"]]]: [(name, plugin_class)] """ - plugin_eps = pkg_resources.iter_entry_points("ofxstatement") - return sorted((ep.name, ep.load()) for ep in plugin_eps) + plugin_eps = list(entry_points(group="ofxstatement")) + return sorted((ep.name, ep.load) for ep in plugin_eps) class PluginNotRegistered(Exception): diff --git a/src/ofxstatement/tool.py b/src/ofxstatement/tool.py index ca6557e..58e3632 100644 --- a/src/ofxstatement/tool.py +++ b/src/ofxstatement/tool.py @@ -9,7 +9,7 @@ import sys import contextlib -import pkg_resources +from importlib.metadata import version from ofxstatement import ui, configuration, plugin, ofx, exceptions from typing import Optional, TextIO, Generator @@ -41,8 +41,7 @@ def smart_open( def get_version() -> str: - dist = pkg_resources.get_distribution("ofxstatement") - return dist.version + return version("ofxstatement") def configure_logging(args: argparse.Namespace) -> None: From 87b293c97c57479ffc1d67244a2798e242900399 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sat, 6 Jan 2024 20:47:15 -0800 Subject: [PATCH 02/24] Change to use the importlib.metadata load method --- src/ofxstatement/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index 611308f..bb2ebcb 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -25,7 +25,7 @@ def list_plugins() -> List[Tuple[str, Type["Plugin"]]]: [(name, plugin_class)] """ plugin_eps = list(entry_points(group="ofxstatement")) - return sorted((ep.name, ep.load) for ep in plugin_eps) + return sorted((ep.name, ep.load()) for ep in plugin_eps) class PluginNotRegistered(Exception): From 6e3bedcddb39304b16823aaf9ec75eb4a63605a3 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 08:48:03 -0800 Subject: [PATCH 03/24] update mocks to entry_points call --- src/ofxstatement/tests/test_plugin.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ofxstatement/tests/test_plugin.py b/src/ofxstatement/tests/test_plugin.py index 275cff4..8adb308 100644 --- a/src/ofxstatement/tests/test_plugin.py +++ b/src/ofxstatement/tests/test_plugin.py @@ -12,10 +12,8 @@ def get_parser(self): return mock.Mock() ep = mock.Mock() - ep.load.return_value = SamplePlugin - - ep_patch = mock.patch("pkg_resources.iter_entry_points", return_value=[ep]) - + ep.attr.load.return_value = SamplePlugin + ep_patch = mock.patch("ofxstatement.plugin.entry_points", return_value=[ep]) with ep_patch: p = plugin.get_plugin("sample", mock.Mock("UI"), mock.Mock("Settings")) self.assertIsInstance(p, SamplePlugin) @@ -23,7 +21,7 @@ def get_parser(self): def test_get_plugin_conflict(self) -> None: ep = mock.Mock() - ep_patch = mock.patch("pkg_resources.iter_entry_points", return_value=[ep, ep]) + ep_patch = mock.patch("ofxstatement.plugin.entry_points", return_value=[ep, ep]) with ep_patch: with self.assertRaises(plugin.PluginNameConflict): plugin.get_plugin("conflicting", mock.Mock("UI"), mock.Mock("Settings")) From 0f3e9f501f7ab9df740dcafe9e2cddd35da4bc7b Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 08:49:07 -0800 Subject: [PATCH 04/24] refactor to only call entry_points once and fix the argument called --- src/ofxstatement/plugin.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index bb2ebcb..1b5d36d 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -10,12 +10,14 @@ from ofxstatement.parser import AbstractStatementParser def get_plugin(name: str, ui: UI, settings: MutableMapping) -> "Plugin": - if not entry_points(group=name): + plugins = entry_points(name=name) + print(plugins) + if not plugins: raise PluginNotRegistered(name) - if len(entry_points(group=name)) > 1: + if len(plugins) > 1: raise PluginNameConflict(plugins) - pcls = entry_points(group=name).attr - plugin = pcls.load() + #pcls = plugins.attr + plugin = plugins[0].attr.load() return plugin(ui,settings) @@ -24,7 +26,7 @@ def list_plugins() -> List[Tuple[str, Type["Plugin"]]]: [(name, plugin_class)] """ - plugin_eps = list(entry_points(group="ofxstatement")) + plugin_eps = entry_points(group="ofxstatement") return sorted((ep.name, ep.load()) for ep in plugin_eps) From 111858fbb55869766bedacf0e4ddf26193160a63 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 08:51:21 -0800 Subject: [PATCH 05/24] remove unncessary pkg_resources references --- Pipfile | 1 - Pipfile.lock | 18 +++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Pipfile b/Pipfile index 366a218..65971fb 100644 --- a/Pipfile +++ b/Pipfile @@ -9,7 +9,6 @@ pytest-cov = "*" mock = "*" black = "*" mypy = "*" -types-pkg-resources = "*" types-mock = "*" exceptiongroup = {markers="python_version < '3.11'"} tomli = {markers="python_version < '3.11'"} diff --git a/Pipfile.lock b/Pipfile.lock index f077e15..19a6f98 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "a2f478d6c67f3d7fb4e3bc8dfd474a88a5902846c518162ac5c5f6bf7e1cbd72" + "sha256": "ad5c20d24aabe639944675c072fe7281c2a2caf625a5b2a3176ca2c1f82b2e51" }, "pipfile-spec": 6, "requires": {}, @@ -262,20 +262,12 @@ }, "types-mock": { "hashes": [ - "sha256:e5821fdfd57bd545b101dc42373b0112027a1e53e82afbd801c122840b3a2780", - "sha256:eeeac25480287bb721fb17fcda2e9768d70a476dcc14a2c1d0389535c54f8184" + "sha256:13ca379d5710ccb3f18f69ade5b08881874cb83383d8fb49b1d4dac9d5c5d090", + "sha256:3d116955495935b0bcba14954b38d97e507cd43eca3e3700fc1b8e4f5c6bf2c7" ], "index": "pypi", - "markers": "python_version >= '3.7'", - "version": "==5.1.0.3" - }, - "types-pkg-resources": { - "hashes": [ - "sha256:0cb9972cee992249f93fff1a491bf2dc3ce674e5a1926e27d4f0866f7d9b6d9c", - "sha256:834a9b8d3dbea343562fd99d5d3359a726f6bf9d3733bccd2b4f3096fbab9dae" - ], - "index": "pypi", - "version": "==0.1.3" + "markers": "python_version >= '3.8'", + "version": "==5.1.0.20240106" }, "typing-extensions": { "hashes": [ From b34a0a2311518936d2e5261876349e343705ef60 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 09:44:12 -0800 Subject: [PATCH 06/24] Updated lockfile --- Pipfile.lock | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Pipfile.lock b/Pipfile.lock index a4d37a0..2fa32cc 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -253,19 +253,12 @@ "version": "==4.1.0" }, "tomli": { - "hashes": [ - "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", - "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" - ], - "markers": "python_version < '3.11'", - "version": "==2.0.1" + "markers": "python_version < '3.11'" }, "types-mock": { "hashes": [ "sha256:13ca379d5710ccb3f18f69ade5b08881874cb83383d8fb49b1d4dac9d5c5d090", "sha256:3d116955495935b0bcba14954b38d97e507cd43eca3e3700fc1b8e4f5c6bf2c7" - "sha256:13ca379d5710ccb3f18f69ade5b08881874cb83383d8fb49b1d4dac9d5c5d090", - "sha256:3d116955495935b0bcba14954b38d97e507cd43eca3e3700fc1b8e4f5c6bf2c7" ], "index": "pypi", "markers": "python_version >= '3.8'", From 0994a0ea7c3341959255d257798fc448792d6bba Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 11:02:20 -0800 Subject: [PATCH 07/24] fix call to get EntryPoint object --- src/ofxstatement/plugin.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index 1b5d36d..6a95ecc 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -11,13 +11,11 @@ def get_plugin(name: str, ui: UI, settings: MutableMapping) -> "Plugin": plugins = entry_points(name=name) - print(plugins) if not plugins: raise PluginNotRegistered(name) if len(plugins) > 1: raise PluginNameConflict(plugins) - #pcls = plugins.attr - plugin = plugins[0].attr.load() + plugin = plugins[0].load() return plugin(ui,settings) From b59deb279f188ea8aa7ffbb116ca70be9d12a3e4 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 11:02:49 -0800 Subject: [PATCH 08/24] Adjust Mock to return correct EntryPoint value --- src/ofxstatement/tests/test_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ofxstatement/tests/test_plugin.py b/src/ofxstatement/tests/test_plugin.py index 8adb308..34618d1 100644 --- a/src/ofxstatement/tests/test_plugin.py +++ b/src/ofxstatement/tests/test_plugin.py @@ -12,7 +12,7 @@ def get_parser(self): return mock.Mock() ep = mock.Mock() - ep.attr.load.return_value = SamplePlugin + ep.load.return_value = SamplePlugin ep_patch = mock.patch("ofxstatement.plugin.entry_points", return_value=[ep]) with ep_patch: p = plugin.get_plugin("sample", mock.Mock("UI"), mock.Mock("Settings")) From 633972f85bac7b3779b999dddac14ea0c2bd3953 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 11:03:47 -0800 Subject: [PATCH 09/24] run Black to fix formatting --- src/ofxstatement/plugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index 6a95ecc..5f38a46 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -9,14 +9,15 @@ from ofxstatement.ui import UI from ofxstatement.parser import AbstractStatementParser + def get_plugin(name: str, ui: UI, settings: MutableMapping) -> "Plugin": plugins = entry_points(name=name) - if not plugins: + if not plugins: raise PluginNotRegistered(name) if len(plugins) > 1: raise PluginNameConflict(plugins) plugin = plugins[0].load() - return plugin(ui,settings) + return plugin(ui, settings) def list_plugins() -> List[Tuple[str, Type["Plugin"]]]: From 2a3f524931a85ede92098cf123b785e69a95bffb Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 21:05:15 -0800 Subject: [PATCH 10/24] fix missing tomli hashes --- Pipfile.lock | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Pipfile.lock b/Pipfile.lock index 2fa32cc..19a6f98 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -253,7 +253,12 @@ "version": "==4.1.0" }, "tomli": { - "markers": "python_version < '3.11'" + "hashes": [ + "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", + "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" + ], + "markers": "python_version < '3.11'", + "version": "==2.0.1" }, "types-mock": { "hashes": [ From d45038e597d7220e1c5ea527cb3ce6779822b815 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 21:32:01 -0800 Subject: [PATCH 11/24] use import_metadata for older versions of python without import.metadata --- src/ofxstatement/plugin.py | 5 ++++- src/ofxstatement/tool.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index 5f38a46..50e9a3e 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -4,7 +4,10 @@ """ from typing import List, Tuple, Type from collections.abc import MutableMapping -from importlib.metadata import entry_points +try: + from importlib.metadata import entry_points +except ImportError: + from importlib_metadata import entry_points from ofxstatement.ui import UI from ofxstatement.parser import AbstractStatementParser diff --git a/src/ofxstatement/tool.py b/src/ofxstatement/tool.py index 58e3632..a1c7511 100644 --- a/src/ofxstatement/tool.py +++ b/src/ofxstatement/tool.py @@ -9,7 +9,10 @@ import sys import contextlib -from importlib.metadata import version +try: + from importlib.metadata import version +except ImportError: + from importlib_metadata import version from ofxstatement import ui, configuration, plugin, ofx, exceptions from typing import Optional, TextIO, Generator From 5a90f8e0475db7271a242678c938600e5fccf084 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 22:02:37 -0800 Subject: [PATCH 12/24] add importlib_metadata for backport of importlib calls --- Pipfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Pipfile b/Pipfile index 65971fb..1c2a68e 100644 --- a/Pipfile +++ b/Pipfile @@ -16,3 +16,4 @@ tomli = {markers="python_version < '3.11'"} [packages] ofxstatement = {editable = true,path = "."} exceptiongroup = "*" +importlib_metadata = {version = ">=3.8", markers="python_version < '3.12'"} \ No newline at end of file From 905869a8a6b3c283f4ad6b063eb8ee9b7f6c5205 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 22:03:51 -0800 Subject: [PATCH 13/24] run black on file --- src/ofxstatement/plugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index 50e9a3e..c135b6d 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -4,6 +4,7 @@ """ from typing import List, Tuple, Type from collections.abc import MutableMapping + try: from importlib.metadata import entry_points except ImportError: From 9a13dab4acc2e2f41c6d4285cdcc7c57b939c3e9 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 22:18:05 -0800 Subject: [PATCH 14/24] python 3.10 already importlib.metadata in stdlib --- Pipfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index 1c2a68e..2284bd1 100644 --- a/Pipfile +++ b/Pipfile @@ -16,4 +16,4 @@ tomli = {markers="python_version < '3.11'"} [packages] ofxstatement = {editable = true,path = "."} exceptiongroup = "*" -importlib_metadata = {version = ">=3.8", markers="python_version < '3.12'"} \ No newline at end of file +importlib_metadata = {version = ">=3.8", markers="python_version < '3.10'"} \ No newline at end of file From 3c94f9ce8fd008980dbe4dab3f5d875ca2cc6dc2 Mon Sep 17 00:00:00 2001 From: Lorenzo Giudici Date: Sun, 7 Jan 2024 17:34:34 +0100 Subject: [PATCH 15/24] Add Hype pPlugin --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 3c2a24c..51805a6 100644 --- a/README.rst +++ b/README.rst @@ -138,6 +138,7 @@ Plugin Description `ofxstatement-n26`_ N26 Bank (Italy) `ofxstatement-it-banks`_ Widiba and Webank (Italy) `ofxstatement-bancoposta`_ BancoPosta - Poste Italiane (Italy) +`ofxstatement-hype`_ Hype - Banca Sella (Italy) `ofxstatement-betterment`_ Betterment (USA) `ofxstatement-us-first-republic`_ First Republic Bank (USA) @@ -218,6 +219,7 @@ Plugin Description .. _ofxstatement-mastercard-de: https://github.com/FliegendeWurst/ofxstatement-mastercard-de .. _ofxstatement-sparkasse-de: https://github.com/FliegendeWurst/ofxstatement-sparkasse-de .. _ofxstatement-bancoposta: https://github.com/lorenzogiudici5/ofxstatement-bancoposta +.. _ofxstatement-hype: https://github.com/lorenzogiudici5/ofxstatement-hype Advanced Configuration ====================== From b33015158cd560b611bd85ea7657250edc870bba Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sun, 7 Jan 2024 09:44:12 -0800 Subject: [PATCH 16/24] Updated lockfile --- Pipfile.lock | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Pipfile.lock b/Pipfile.lock index 19a6f98..2fa32cc 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -253,12 +253,7 @@ "version": "==4.1.0" }, "tomli": { - "hashes": [ - "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", - "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" - ], - "markers": "python_version < '3.11'", - "version": "==2.0.1" + "markers": "python_version < '3.11'" }, "types-mock": { "hashes": [ From a2cd940423989f7eb8c06d857656fa6417536c1e Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Fri, 12 Jan 2024 09:04:32 -0800 Subject: [PATCH 17/24] update pipfile.lock with importlib_metadata and dependencies --- Pipfile.lock | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Pipfile.lock b/Pipfile.lock index 2fa32cc..0f90a22 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -30,9 +30,25 @@ "markers": "python_version >= '3.7'", "version": "==1.2.0" }, + "importlib-metadata": { + "hashes": [ + "sha256:4805911c3a4ec7c3966410053e9ec6a1fecd629117df5adee56dfc9432a1081e", + "sha256:f238736bb06590ae52ac1fab06a3a9ef1d8dce2b7a35b5ab329371d6c8f5d2cc" + ], + "index": "pypi", + "markers": "python_version < '3.10'", + "version": "==7.0.1" + }, "ofxstatement": { "editable": true, "path": "." + }, + "zipp": { + "hashes": [ + "sha256:0e923e726174922dce09c53c59ad483ff7bbb8e572e00c7f7c46b88556409f31", + "sha256:84e64a1c28cf7e91ed2078bb8cc8c259cb19b76942096c8d7b84947690cabaf0" + ], + "version": "==3.17.0" } }, "develop": { @@ -253,7 +269,13 @@ "version": "==4.1.0" }, "tomli": { - "markers": "python_version < '3.11'" + "hashes": [ + "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", + "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" + ], + "index": "pypi", + "markers": "python_version < '3.11'", + "version": "==2.0.1" }, "types-mock": { "hashes": [ From bf1dfceb982db812318489b415980f6f6abfdd9e Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sat, 13 Jan 2024 11:37:14 -0800 Subject: [PATCH 18/24] try importlib_metadata first for python below 3.10 --- src/ofxstatement/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index c135b6d..4e3d326 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -6,9 +6,9 @@ from collections.abc import MutableMapping try: - from importlib.metadata import entry_points -except ImportError: from importlib_metadata import entry_points +except ImportError: + from importlib.metadata import entry_points # type: ignore[assignment] #need when importlib_metadata is present from ofxstatement.ui import UI from ofxstatement.parser import AbstractStatementParser From 244e7421aeb0cad746c0ee5f37a8bebae27a594e Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sat, 13 Jan 2024 11:38:59 -0800 Subject: [PATCH 19/24] Fix typing conflict between mypy and pytest --- src/ofxstatement/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index 4e3d326..da523ef 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -20,7 +20,7 @@ def get_plugin(name: str, ui: UI, settings: MutableMapping) -> "Plugin": raise PluginNotRegistered(name) if len(plugins) > 1: raise PluginNameConflict(plugins) - plugin = plugins[0].load() + plugin = plugins[0].load() # type: ignore[index] # index requires a int but class expects a string return plugin(ui, settings) From c8b002e02bcf063cf81bd4e7cfead2aaad8ec752 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sat, 13 Jan 2024 11:40:21 -0800 Subject: [PATCH 20/24] try importlib_metadata first for python below 3.10 --- src/ofxstatement/tool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ofxstatement/tool.py b/src/ofxstatement/tool.py index a1c7511..4d5ce1d 100644 --- a/src/ofxstatement/tool.py +++ b/src/ofxstatement/tool.py @@ -10,9 +10,9 @@ import contextlib try: - from importlib.metadata import version -except ImportError: from importlib_metadata import version +except ImportError: + from importlib.metadata import version from ofxstatement import ui, configuration, plugin, ofx, exceptions from typing import Optional, TextIO, Generator From 994e24283747218ace51ad5563b6b3f200d26b81 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sat, 13 Jan 2024 11:43:12 -0800 Subject: [PATCH 21/24] updated markers on zipp --- Pipfile.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Pipfile.lock b/Pipfile.lock index 0f90a22..f56bba1 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "ad5c20d24aabe639944675c072fe7281c2a2caf625a5b2a3176ca2c1f82b2e51" + "sha256": "9eff26da7c0885e82355bd0e9d77d60f3ebee69507ba41b063a5a5599ccc6f6f" }, "pipfile-spec": 6, "requires": {}, @@ -48,6 +48,7 @@ "sha256:0e923e726174922dce09c53c59ad483ff7bbb8e572e00c7f7c46b88556409f31", "sha256:84e64a1c28cf7e91ed2078bb8cc8c259cb19b76942096c8d7b84947690cabaf0" ], + "markers": "python_version < '3.10' and python_version >= '3.8'", "version": "==3.17.0" } }, From 3548cc56a9cf3cd9059f03978f699bac60525b56 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sat, 13 Jan 2024 11:45:09 -0800 Subject: [PATCH 22/24] black formatting fix --- src/ofxstatement/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index da523ef..ff854d3 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -8,7 +8,7 @@ try: from importlib_metadata import entry_points except ImportError: - from importlib.metadata import entry_points # type: ignore[assignment] #need when importlib_metadata is present + from importlib.metadata import entry_points # type: ignore[assignment] #need when importlib_metadata is present from ofxstatement.ui import UI from ofxstatement.parser import AbstractStatementParser @@ -20,7 +20,7 @@ def get_plugin(name: str, ui: UI, settings: MutableMapping) -> "Plugin": raise PluginNotRegistered(name) if len(plugins) > 1: raise PluginNameConflict(plugins) - plugin = plugins[0].load() # type: ignore[index] # index requires a int but class expects a string + plugin = plugins[0].load() # type: ignore[index] # index requires a int but class expects a string return plugin(ui, settings) From f63888ccbdababeb5d01f95c4e4fca918d7ed55b Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sat, 13 Jan 2024 18:12:54 -0800 Subject: [PATCH 23/24] change decision between importlib modules to be more specific --- src/ofxstatement/plugin.py | 7 ++++--- src/ofxstatement/tool.py | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ofxstatement/plugin.py b/src/ofxstatement/plugin.py index ff854d3..9eaf532 100644 --- a/src/ofxstatement/plugin.py +++ b/src/ofxstatement/plugin.py @@ -4,11 +4,12 @@ """ from typing import List, Tuple, Type from collections.abc import MutableMapping +import sys -try: +if sys.version_info < (3, 10): from importlib_metadata import entry_points -except ImportError: - from importlib.metadata import entry_points # type: ignore[assignment] #need when importlib_metadata is present +else: + from importlib.metadata import entry_points from ofxstatement.ui import UI from ofxstatement.parser import AbstractStatementParser diff --git a/src/ofxstatement/tool.py b/src/ofxstatement/tool.py index 4d5ce1d..90bd0b6 100644 --- a/src/ofxstatement/tool.py +++ b/src/ofxstatement/tool.py @@ -9,11 +9,12 @@ import sys import contextlib -try: +if sys.version_info < (3, 10): from importlib_metadata import version -except ImportError: +else: from importlib.metadata import version + from ofxstatement import ui, configuration, plugin, ofx, exceptions from typing import Optional, TextIO, Generator From 653f990ee2bf49d26f2215bb990f7fce9064e179 Mon Sep 17 00:00:00 2001 From: Jake Cadwell Date: Sat, 13 Jan 2024 18:31:24 -0800 Subject: [PATCH 24/24] add importlib_metadata dependency for python earlier than 3.10 --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 502d8e8..c25c1ad 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,6 +25,7 @@ packages = find: python_requires = >=3.8, <4 install_requires = appdirs>=1.3.0 + importlib_metadata>=3.8;python_version<'3.10' data_files = [options.packages.find]