def METHOD_NAME(self, file: TextFileType, /, **kwargs: Any) -> TextFileType:
    """Render a given file in-place."""
    original_path = file.source_path
    try:
        source = file.text
        with self.error_handler("Couldn't render file."):
            template = self.compile(source, filename=original_path)
            file.text = template.render(kwargs)
        return file
    except OSError:
        if not original_path:
            raise
    file.text = self.render(str(original_path), **kwargs)
    return file