Skip to content

Editor temp files breaks auto reloading due to a ValueError: <file> is not in the subpath of '.' #731

@frmdstryr

Description

@frmdstryr

I have a simple aiohttp app in a package solarpi. When run using adev runserver solarpi and making a change my editor (KDevelop) sometimes creates temporary .kate-swp files that cause the following error:

[08:38:02] '/home/usr/projects/solar-pi/solarpi/templates/.index.html.kate-swp' is not in the subpath of '.'
Traceback (most recent call last):
  File "/home/usr/.local/share/mamba/envs/solarpi/lib/python3.13/site-packages/aiohttp_devtools/runserver/watch.py", line 97, in _run
    await src_reload(self._app, changes.pop()[1])
  File "/home/usr/.local/share/mamba/envs/solarpi/lib/python3.13/site-packages/aiohttp_devtools/runserver/serve.py", line 221, in src_reload
    path = str(Path(app[STATIC_URL]) / Path(path).relative_to(app[STATIC_PATH]))
                                       ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/usr/.local/share/mamba/envs/solarpi/lib/python3.13/pathlib/_local.py", line 385, in relative_to
    raise ValueError(f"{str(self)!r} is not in the subpath of {str(other)!r}")
ValueError: '/home/usr/projects/solar-pi/solarpi/templates/.index.html.kate-swp' is not in the subpath of '.'

After this error reloading stops working. Adding a try/except around that appears to fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions