You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid infinite loop in module_name_from_path (#89)
`Path(".").parent` can't move past the "." in a relative path and will
just return `Path(".")` again. This lead to `while True` never breaking.
To fix this, we make sure that absolute paths are used. We need to
resolve the `path` before `lru_cache` sees it. Otherwise, `lru_cache`
might return a wrong cached result in case the current working directory
changes. That should never happen in docstub, but I think it's still
good to be defensive here.
This change also adds a few other defensive guards and asserts.
Long term, it might be the least error-prone to resolve all paths to
absolute ones as soon as possible. However, we'd have to do some
additional work to shorten paths that are within the current working
directory. Otherwise, users might see unnecessarily long paths in
their output.
Also:
- Warn in case docstub is run on a subpackage only
- Appease mypy pointing out call to untyped function in tests
- Appease mypy pointing out a missing return type annotation
---------
Co-authored-by: Lars Grüter <lagru@mailbox.org>
0 commit comments