Repository: Lightning-AI/pytorch-lightning
File: pytorch_lightning/callbacks/model_checkpoint.py (Python)

Code before:
        # Mode 2: save the last checkpoint
        self._save_last_checkpoint(trainer, pl_module, epoch, monitor_candidates, filepath)

    def __validate_init_configuration(self):
        if self.save_top_k is not None and self.save_top_k < -1:
            raise MisconfigurationException(
                f'Invalid value for save_top_k={self.save_top_k}. Must be None or >= -1'
            )
        if self.monitor is None:
            # None: save last epoch, -1: save all epochs, 0: nothing is saved
            if self.save_top_k not in [None, -1, 0]:
                raise MisconfigurationException(
                    f'ModelCheckpoint(save_top_k={self.save_top_k}, monitor=None) is not a valid'
                    ' configuration. No quantity for top_k to track.'
                )
            if self.save_last:
                raise MisconfigurationException(
                    'ModelCheckpoint(save_last=True, monitor=None) is not a valid configuration.'
                    ' You can save the last checkpoint with ModelCheckpoint(save_top_k=None, monitor=None)'
                )

    def __init_ckpt_dir(self, filepath, dirpath, filename, save_top_k):
        if filepath:
            if (dirpath or filename):
                raise MisconfigurationException(
                    f'You have set all three path/name inputs which are not feasible.'
                    f' You have to choose either filepath={filepath} OR dirpath={dirpath}'
                    f' and filename={filename} configuration.'
                )

            rank_zero_warn(
                'Argument `filepath` is deprecated in v1.0 and will be removed in v1.2.'
                ' Please use `dirpath` and `filename` instead.', DeprecationWarning
            )

            _fs = get_filesystem(filepath)

            if _fs.isdir(filepath):
                dirpath, filename = filepath, None
            else:
                if _fs.protocol == 'file':
                    filepath = os.path.realpath(filepath)
                dirpath, filename = os.path.split(filepath)

        self._fs = get_filesystem(str(dirpath) if dirpath else '')

        if (
            save_top_k is not None
            and save_top_k > 0
            and dirpath is not None
            and self._fs.isdir(dirpath)

Review comment (suggestion):
```suggestion
                    'You have set all three path/name inputs which are not feasible.'
```

Code after:
        # Mode 2: save the last checkpoint
        self._save_last_checkpoint(trainer, pl_module, epoch, monitor_candidates, filepath)

    def __validate_init_configuration(self):
        if self.save_top_k is not None and self.save_top_k < -1:
            raise MisconfigurationException(
                f'Invalid value for save_top_k={self.save_top_k}. Must be None or >= -1'
            )
        if self.monitor is None:
            # None: save last epoch, -1: save all epochs, 0: nothing is saved
            if self.save_top_k not in [None, -1, 0]:
                raise MisconfigurationException(
                    f'ModelCheckpoint(save_top_k={self.save_top_k}, monitor=None) is not a valid'
                    ' configuration. No quantity for top_k to track.'
                )
            if self.save_last:
                raise MisconfigurationException(
                    'ModelCheckpoint(save_last=True, monitor=None) is not a valid configuration.'
                    ' You can save the last checkpoint with ModelCheckpoint(save_top_k=None, monitor=None)'
                )

    def __init_ckpt_dir(self, filepath, dirpath, filename, save_top_k):
        if filepath:
            if (dirpath or filename):
                raise MisconfigurationException(
                    'You have set all three path/name inputs which are not feasible.'
                    f' You have to choose either filepath={filepath} OR dirpath={dirpath}'
                    f' and filename={filename} configuration.'
                )

            rank_zero_warn(
                'Argument `filepath` is deprecated in v1.0 and will be removed in v1.2.'
                ' Please use `dirpath` and `filename` instead.', DeprecationWarning
            )

            _fs = get_filesystem(filepath)

            if _fs.isdir(filepath):
                dirpath, filename = filepath, None
            else:
                if _fs.protocol == 'file':
                    filepath = os.path.realpath(filepath)
                dirpath, filename = os.path.split(filepath)

        self._fs = get_filesystem(str(dirpath) if dirpath else '')

        if (
            save_top_k is not None
            and save_top_k > 0
            and dirpath is not None
            and self._fs.isdir(dirpath)