From 88f9e923e8e6cf78bd90ffc19fb1092a4fc10b2a Mon Sep 17 00:00:00 2001
From: Marc Wouts <marc.wouts@gmail.com>
Date: Thu, 15 Jul 2021 01:10:48 +0200
Subject: [PATCH 1/3] Test that a simple notebook can be trusted

---
 tests/test_trust_notebook.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/test_trust_notebook.py b/tests/test_trust_notebook.py
index b06538c2d..238ce7154 100644
--- a/tests/test_trust_notebook.py
+++ b/tests/test_trust_notebook.py
@@ -143,3 +143,23 @@ def test_text_notebooks_can_be_trusted(nb_file, tmpdir, no_jupytext_version_numb
     model = cm.get(file)
     for cell in model["content"].cells:
         assert cell.metadata.get("trusted", True)
+
+
+def test_simple_notebook_is_trusted(tmpdir, python_notebook):
+    cm = TextFileContentsManager()
+    cm.root_dir = str(tmpdir)
+
+    nb = python_notebook
+    cm.notary.unsign(nb)
+
+    # All cells are trusted in this notebook
+    assert cm.notary.check_cells(nb)
+    # Yet the notebook is not in the database of trusted notebooks
+    assert not cm.notary.check_signature(nb)
+
+    # Save the notebook using the CM
+    cm.save(dict(type="notebook", content=nb), "test.ipynb")
+
+    # The notebook is safe so it should have been trusted before getting saved to disk
+    nb = cm.get("test.ipynb")["content"]
+    assert cm.notary.check_signature(nb)

From e9fd678b02186533aad38751404dacc6f6809918 Mon Sep 17 00:00:00 2001
From: Marc Wouts <marc.wouts@gmail.com>
Date: Thu, 15 Jul 2021 02:07:53 +0200
Subject: [PATCH 2/3] Cell ids were added to JupyterLab in 3.0.13

---
 environment.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/environment.yml b/environment.yml
index c4f196f3c..2f27cbbe7 100644
--- a/environment.yml
+++ b/environment.yml
@@ -4,7 +4,7 @@ channels:
   - conda-forge
 dependencies:
   - python>=3.6
-  - jupyterlab>=3.0
+  - jupyterlab>=3.0.13
   - nbformat>=5.1.2
   - jupyter-packaging
   - pyyaml

From 04b5281b5501a54b3c8480d0cc5d2c51df5aa057 Mon Sep 17 00:00:00 2001
From: Marc Wouts <marc.wouts@gmail.com>
Date: Thu, 15 Jul 2021 02:13:40 +0200
Subject: [PATCH 3/3] No need to add the "trusted" metadata manually

---
 jupytext/contentsmanager.py | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/jupytext/contentsmanager.py b/jupytext/contentsmanager.py
index 8f3a60961..e113cc61e 100644
--- a/jupytext/contentsmanager.py
+++ b/jupytext/contentsmanager.py
@@ -343,15 +343,6 @@ def read_one_file(alt_path, alt_fmt):
             if not outputs.timestamp:
                 set_kernelspec_from_language(model["content"])
 
-            # Trust code cells when they have no output
-            for cell in model["content"].cells:
-                if (
-                    cell.cell_type == "code"
-                    and not cell.outputs
-                    and cell.metadata.get("trusted") is False
-                ):
-                    cell.metadata["trusted"] = True
-
             return model
 
         def new_untitled(self, path="", type="", ext=""):