Skip to content

Commit

Permalink
Introduce class parameter to be able to control the omit none functio…
Browse files Browse the repository at this point in the history
…nality easily #71
  • Loading branch information
jh-RLI committed Jan 19, 2024
1 parent 2c7e970 commit 3b02795
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/omi/dialects/oep/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def compile_date_or_none(x, format=None):

class JSONCompiler(Compiler):
__METADATA_VERSION = "OEP-1.4.0"
OMIT_NONE_FIELDS = False

def _construct_dict(self, *args, omit_none=False, **kwargs):
def _construct_dict(self, *args, omit_none=None, **kwargs):
"""
Accepts a list of arguments of shape (name: str, field: Compileable) and returns a dictionary that maps
name -> self.visit(field). If `omit_none` is true, fields that are `None` are ignored.
Expand All @@ -32,6 +33,7 @@ def _construct_dict(self, *args, omit_none=False, **kwargs):
-------
"""
omit_none = self.OMIT_NONE_FIELDS
d = {
field_name: self.visit(field)
for field_name, field in args
Expand Down

0 comments on commit 3b02795

Please sign in to comment.