def setdefault(
        self, item, default, apply_default_on_none=False, env: str = "unknown"
    ):
        """Returns value if exists or set it as the given default

        apply_default_on_none: if True, default is set when value is None
        env: used to create the source identifier
        """
        value = self.get(item, empty)

        # Yaml loader reads empty values as None, would we apply defaults?
        global_apply_default = (
            self.get("APPLY_DEFAULT_ON_NONE_FOR_DYNACONF") is not None
        )
        apply_default = default is not empty and (
            value is empty
            or (
                value is None
                and (
                    apply_default_on_none is True
                    or global_apply_default is True
                )
            )
        )
        loader_identifier = SourceMetadata("setdefault", "unique", env.lower())

        if apply_default:
            self.set(
                item,
                default,
                loader_identifier=loader_identifier,
                tomlfy=True,
            )
            return default

        return value
Returns value if exists or set it as the given default

        apply_default_on_none: if True, default is set when value is None
        env: used to create the source identifier
        
dynaconf/base.py