From 4f68a2f36033184eaeb2c541877982531102dc65 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 29 Jun 2025 11:18:13 -0500 Subject: [PATCH 1/4] docs: fix some warnings etc. --- src/wuttasync/importing/handlers.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wuttasync/importing/handlers.py b/src/wuttasync/importing/handlers.py index ac3f89f..ec367ab 100644 --- a/src/wuttasync/importing/handlers.py +++ b/src/wuttasync/importing/handlers.py @@ -232,7 +232,7 @@ class ImportHandler(GenericHandler): """ Run import/export operations for the specified models. - :param \*keys: One or more importer/exporter (model) keys, as + :param \\*keys: One or more importer/exporter (model) keys, as defined by the handler. Each key specified must be present in :attr:`importers` and @@ -460,6 +460,9 @@ class ImportHandler(GenericHandler): Returns an importer/exporter instance corresponding to the given key. + Note that this will always create a *new* instance; they are + not cached. + The key will be the "model name" mapped to a particular importer/exporter class and thus must be present in :attr:`importers`. @@ -472,6 +475,8 @@ class ImportHandler(GenericHandler): :param key: Model key for desired importer/exporter. + :param \\**kwargs: Extra/override kwargs for the importer. + :returns: Instance of (subclass of) :class:`~wuttasync.importing.base.Importer`. """ @@ -493,7 +498,7 @@ class ImportHandler(GenericHandler): :param key: Model key for the desired importer/exporter, e.g. ``'Widget'`` - :param \**kwargs: Any kwargs we have so collected far. + :param \\**kwargs: Any kwargs we have so collected far. :returns: Final kwargs dict for new importer/exporter. """ From 65bbc95ae2df8e6da928d7c82a8129f4fab1ecc5 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 29 Jun 2025 11:19:10 -0500 Subject: [PATCH 2/4] fix: do not assign simple/supported fields in Importer constructor subclass may define those and we do not want to overwrite; in some cases doing so would cause error (if subclass defines a property) --- src/wuttasync/importing/base.py | 2 -- tests/importing/test_base.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/wuttasync/importing/base.py b/src/wuttasync/importing/base.py index 59017d7..6e06cfb 100644 --- a/src/wuttasync/importing/base.py +++ b/src/wuttasync/importing/base.py @@ -200,8 +200,6 @@ class Importer: self.__dict__.update(kwargs) - self.simple_fields = self.get_simple_fields() - self.supported_fields = self.get_supported_fields() self.fields = self.get_fields() # fields could be comma-delimited string from cli param diff --git a/tests/importing/test_base.py b/tests/importing/test_base.py index ff2ca6e..feab115 100644 --- a/tests/importing/test_base.py +++ b/tests/importing/test_base.py @@ -24,8 +24,6 @@ class TestImporter(DataTestCase): imp = self.make_importer(model_class=model.Setting) # fields - self.assertEqual(imp.supported_fields, ['name', 'value']) - self.assertEqual(imp.simple_fields, ['name', 'value']) self.assertEqual(imp.fields, ['name', 'value']) # orientation etc. From 6c94b13b12592b37fac6d0e5dba911c9dc00bc72 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 29 Jun 2025 11:24:10 -0500 Subject: [PATCH 3/4] fix: avoid empty keys for importer when keys come in from command line params, the arg parser may have an empty value. which we need to avoid here --- src/wuttasync/importing/handlers.py | 5 +++++ tests/importing/test_handlers.py | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/wuttasync/importing/handlers.py b/src/wuttasync/importing/handlers.py index ec367ab..03a6179 100644 --- a/src/wuttasync/importing/handlers.py +++ b/src/wuttasync/importing/handlers.py @@ -486,6 +486,11 @@ class ImportHandler(GenericHandler): kwargs = self.get_importer_kwargs(key, **kwargs) kwargs['handler'] = self + + # nb. default logic should (normally) determine keys + if 'keys' in kwargs and not kwargs['keys']: + del kwargs['keys'] + factory = self.importers[key] return factory(self.config, **kwargs) diff --git a/tests/importing/test_handlers.py b/tests/importing/test_handlers.py index dac37d6..3c2fe49 100644 --- a/tests/importing/test_handlers.py +++ b/tests/importing/test_handlers.py @@ -169,6 +169,18 @@ class TestImportHandler(DataTestCase): importer = handler.get_importer('Setting', model_class=model.Setting) self.assertIsInstance(importer, Importer) + # specifying empty keys + handler.importers['Setting'] = Importer + importer = handler.get_importer('Setting', model_class=model.Setting, + keys=None) + self.assertIsInstance(importer, Importer) + importer = handler.get_importer('Setting', model_class=model.Setting, + keys='') + self.assertIsInstance(importer, Importer) + importer = handler.get_importer('Setting', model_class=model.Setting, + keys=[]) + self.assertIsInstance(importer, Importer) + # key not found self.assertRaises(KeyError, handler.get_importer, 'BunchOfNonsense', model_class=model.Setting) From c4a0b038e88bfd542df85554f25e9dcd515e18bf Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 29 Jun 2025 11:25:14 -0500 Subject: [PATCH 4/4] =?UTF-8?q?bump:=20version=200.2.0=20=E2=86=92=200.2.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05f5ef3..4b1fd1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to WuttaSync will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## v0.2.1 (2025-06-29) + +### Fix + +- avoid empty keys for importer +- do not assign simple/supported fields in Importer constructor +- make `--input-path` optional for import/export commands + ## v0.2.0 (2024-12-07) ### Feat diff --git a/pyproject.toml b/pyproject.toml index a198b0e..fc09dc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "WuttaSync" -version = "0.2.0" +version = "0.2.1" description = "Wutta Framework for data import/export and real-time sync" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@wuttaproject.org"}]