code: def test_pre_commit_hook_with_subfolders_issue_506(tmpdir):
      """I have the following directory structure, where the nb/test.ipynb is paired with the py/test.py.
  
      ├── nb
      │   └── test.ipynb
      └── py
          └── test.py
      """
  
      nb_file = tmpdir.mkdir("nb").join("test.ipynb")
      py_file = tmpdir.mkdir("py").join("test.py")
  
      """The notebook and Python file are paired with "jupytext": {"formats": "py//py,nb//ipynb"}.
          (using jupytext --set-formats py//py,nb//ipynb nb/test.ipynb)"""
      write(
          new_notebook(
              cells=[new_markdown_cell("A Markdown cell")],
              metadata={"jupytext": {"formats": "py//py,nb//ipynb"}},
          ),
          str(py_file),
      )
  
      """This works fine when syncing with jupytext --sync nb/test.ipynb
      but when syncing with jupytext --sync --pre-commit I get the following exception: (...)"""
      git = git_in_tmpdir(tmpdir)
      hook = str(tmpdir.join(".git/hooks/pre-commit"))
      with open(hook, "w") as fp:
          fp.write("#!/bin/sh\n" "jupytext --sync --pre-commit\n")
  
      st = os.stat(hook)
      os.chmod(hook, st.st_mode | stat.S_IEXEC)
  
      assert not os.path.isfile(str(nb_file))
  
      git("add", "py/test.py")
      git("status")
      git("commit", "-m", "notebook created")
      git("status")
  
      assert os.path.isfile(str(nb_file))
      assert read(str(nb_file)).cells[0].source == "A Markdown cell"
  
file_path: jupytext/tests/external/pre_commit/test_pre_commit_scripts.py
imports: import os
  import stat
  import unittest.mock
  import pytest
  from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook
  from jupytext import read, write
  from jupytext.cli import jupytext, system
  from jupytext.compare import compare_cells, compare_notebooks
label_desc: Use image node_id 9 for calling a global function with example usage: test_pre_commit_hook_with_subfolders_issue_506(tmpdir) without return types