Repository: Lightning-AI/pytorch-lightning
File: pytorch_lightning/loggers/base.py (Python)

Code before:
            step: Step number at which the metrics should be recorded
        """
        pass

    @staticmethod
    def _convert_params(params: Union[Dict[str, Any], Namespace]) -> Dict[str, Any]:
        # in case converting from namespace
        if isinstance(params, Namespace):
            params = vars(params)

        if params is None:
            params = {}

        return params

    @staticmethod
    def _sanitize_callable_params(params: Dict[str, Any]) -> Dict[str, Any]:
        """
        Sanitize callable params dict, e.g. ``{'a': <function_**** at 0x*****> -> {'a': 'function_****'}``.

        Args:
            params: Dictionary containing the hyperparameters

        Returns:
            dict.
        """
        def _sanitize_callable(val):
            # Give them one chance to return a value. Don't go rabbit hole of recursive call
            if isinstance(val, Callable):
                try:
                    _val = val()
                    if isinstance(_val, Callable):
                        return val.__name__
                    return _val
                except Exception:
                    return val.__name__
            return val

        return {key: _sanitize_callable(val) for key, val in params.items()}

    @staticmethod
    def _flatten_dict(params: Dict[str, Any], delimiter: str = '/') -> Dict[str, Any]:
        """
        Flatten hierarchical dict, e.g. ``{'a': {'b': 'c'}} -> {'a/b': 'c'}``.

        Args:
            params: Dictionary containing the hyperparameters
            delimiter: Delimiter to express the hierarchy. Defaults to ``'/'``.

        Returns:
            Flattened dict.

Review comment (security):
```suggestion
        """
        Sanitize callable params dict, e.g. ``{'a': <function_**** at 0x****>} -> {'a': 'function_****'}``.

        Args:
            params: Dictionary containing the hyperparameters

        Returns:
            dictionary with all callables sanitized
        """
```

Code after:
            step: Step number at which the metrics should be recorded
        """
        pass

    @staticmethod
    def _convert_params(params: Union[Dict[str, Any], Namespace]) -> Dict[str, Any]:
        # in case converting from namespace
        if isinstance(params, Namespace):
            params = vars(params)

        if params is None:
            params = {}

        return params

    @staticmethod
    def _sanitize_callable_params(params: Dict[str, Any]) -> Dict[str, Any]:
        """
        Sanitize callable params dict, e.g. ``{'a': <function_**** at 0x****>} -> {'a': 'function_****'}``.

        Args:
            params: Dictionary containing the hyperparameters

        Returns:
            dictionary with all callables sanitized
        """
        def _sanitize_callable(val):
            # Give them one chance to return a value. Don't go rabbit hole of recursive call
            if isinstance(val, Callable):
                try:
                    _val = val()
                    if isinstance(_val, Callable):
                        return val.__name__
                    return _val
                except Exception:
                    return val.__name__
            return val

        return {key: _sanitize_callable(val) for key, val in params.items()}

    @staticmethod
    def _flatten_dict(params: Dict[str, Any], delimiter: str = '/') -> Dict[str, Any]:
        """
        Flatten hierarchical dict, e.g. ``{'a': {'b': 'c'}} -> {'a/b': 'c'}``.

        Args:
            params: Dictionary containing the hyperparameters
            delimiter: Delimiter to express the hierarchy. Defaults to ``'/'``.

        Returns:
            Flattened dict.