@@ -89,7 +89,7 @@ def parse_file(cls, filename, encoding='utf-8', required=True, resolve=True, unr
8989 :param unresolved_value: assigned value value to unresolved substitution.
9090 If overriden with a default value, it will replace all unresolved value to the default value.
9191 If it is set to to pyhocon.STR_SUBSTITUTION then it will replace the value by its substitution expression (e.g., ${x})
92- :type unresolved_value: boolean
92+ :type unresolved_value: class
9393 :return: Config object
9494 :type return: Config
9595 """
@@ -484,13 +484,18 @@ def _fixup_self_references(cls, config, accept_unresolved=False):
484484 _ , _ , current_item = cls ._do_substitute (substitution , value )
485485 previous_item = current_item
486486
487- if len (history ) == 1 : # special case, when self optional referencing without existing
487+ if len (history ) == 1 :
488488 for substitution in cls ._find_substitutions (previous_item ):
489489 prop_path = ConfigTree .parse_key (substitution .variable )
490490 if len (prop_path ) > 1 and config .get (substitution .variable , None ) is not None :
491491 continue # If value is present in latest version, don't do anything
492- if prop_path [0 ] == key and substitution .optional :
493- cls ._do_substitute (substitution , None )
492+ if prop_path [0 ] == key :
493+ value = os .environ .get (key )
494+ if value is not None :
495+ cls ._do_substitute (substitution , value )
496+ continue
497+ if substitution .optional : # special case, when self optional referencing without existing
498+ cls ._do_substitute (substitution , None )
494499
495500 # traverse config to find all the substitutions
496501 @classmethod
0 commit comments