Skip to content

Commit

Permalink
Suggesions from review
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet committed Oct 23, 2021
1 parent e29a937 commit d9e86f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion luigi/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
6 changes: 3 additions & 3 deletions test/optional_parameter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit d9e86f1

Please sign in to comment.