How to debug middlewared

Hello, I am a developer, I refer to doc https://github.com/truenas/middleware/blob/master/docs/source/middleware/development.rst#substituting-the-middleware-code-in-an-already-built-image to debug middlewared the code has been successfully mount via nfs to /usr/lib/python3/dist-packages/middlewared but got error

truenas_admin@truenas[...lib/python3/dist-packages/middlewared]$ sudo REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt middlewared --log-handler=console --debug-level DEBUG

[2025/11/12 07:31:23] (INFO) middlewared.__init__():133 - Starting TrueNAS-26.04.0-MASTER-20251022-100604 middleware
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.13/multiprocessing/__init__.py", line 16, in <module>
    from . import context
  File "/usr/lib/python3.13/multiprocessing/context.py", line 3, in <module>
    import threading
  File "/usr/lib/python3.13/threading.py", line 9, in <module>
    from _weakrefset import WeakSet
  File "/usr/lib/python3.13/_weakrefset.py", line 6, in <module>
    from types import GenericAlias
  File "/usr/lib/python3/dist-packages/middlewared/types.py", line 2, in <module>
    from types import TracebackType
ImportError: cannot import name 'TracebackType' from 'types' (consider renaming '/usr/lib/python3/dist-packages/middlewared/types.py' since it has the same name as the standard library module named 'types' and prevents importing that standard library module)

does anyone know the reason? I’ve tried two approaches:

  1. One involves mounting the code from the git repository https://github.com/truenas/middleware/

  2. the other involves copying the contents of the original iso’s /usr/lib/python3/dist-packages/middlewared directory to another machine, then mounting it back via NFS