From d9e86f1d37b37a883bc7be6cefac5ef1aab237e8 Mon Sep 17 00:00:00 2001 From: Adrien Berchet Date: Sat, 23 Oct 2021 23:29:24 +0200 Subject: [PATCH] Suggesions from review --- luigi/parameter.py | 2 +- test/optional_parameter_test.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/luigi/parameter.py b/luigi/parameter.py index fb7f994b38..5ef47c31c0 100644 --- a/luigi/parameter.py +++ b/luigi/parameter.py @@ -335,7 +335,7 @@ class OptionalParameterMixin: Mixin to make a parameter class optional and treat empty string as None. """ - expected_type = str + expected_type = type(None) def serialize(self, x): """ diff --git a/test/optional_parameter_test.py b/test/optional_parameter_test.py index 93b8734d4f..0bddb033ab 100644 --- a/test/optional_parameter_test.py +++ b/test/optional_parameter_test.py @@ -6,7 +6,7 @@ class OptionalParameterTest(LuigiTestCase): - def actual_test(current_test, cls, default, expected_value, expected_type, bad_data, **kwargs): + def actual_test(self, cls, default, expected_value, expected_type, bad_data, **kwargs): class TestConfig(luigi.Config): param = cls(default=default, **kwargs) @@ -17,7 +17,7 @@ def run(self): assert self.empty_param is None # Test parsing empty string (should be None) - current_test.assertIsNone(cls(**kwargs).parse('')) + self.assertIsNone(cls(**kwargs).parse('')) # Test that warning is raised only with bad type with mock.patch('luigi.parameter.warnings') as warnings: @@ -44,7 +44,7 @@ def run(self): ) # Test with value from config - current_test.assertTrue(luigi.build([TestConfig()], local_scheduler=True)) + self.assertTrue(luigi.build([TestConfig()], local_scheduler=True)) @with_config({"TestConfig": {"param": "expected value", "empty_param": ""}}) def test_optional_parameter(self):