Simplified handling of non-existent paths in autoreloader with Path.resolve(strict=True).
This commit is contained in:
parent
833878411c
commit
e286711879
|
@ -136,11 +136,13 @@ def iter_modules_and_files(modules, extra_files):
|
||||||
if not filename:
|
if not filename:
|
||||||
continue
|
continue
|
||||||
path = pathlib.Path(filename)
|
path = pathlib.Path(filename)
|
||||||
if not path.exists():
|
try:
|
||||||
|
resolved_path = path.resolve(strict=True).absolute()
|
||||||
|
except FileNotFoundError:
|
||||||
# The module could have been removed, don't fail loudly if this
|
# The module could have been removed, don't fail loudly if this
|
||||||
# is the case.
|
# is the case.
|
||||||
continue
|
continue
|
||||||
results.add(path.resolve().absolute())
|
results.add(resolved_path)
|
||||||
return frozenset(results)
|
return frozenset(results)
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,14 +184,15 @@ def sys_path_directories():
|
||||||
"""
|
"""
|
||||||
for path in sys.path:
|
for path in sys.path:
|
||||||
path = Path(path)
|
path = Path(path)
|
||||||
if not path.exists():
|
try:
|
||||||
|
resolved_path = path.resolve(strict=True).absolute()
|
||||||
|
except FileNotFoundError:
|
||||||
continue
|
continue
|
||||||
path = path.resolve().absolute()
|
|
||||||
# If the path is a file (like a zip file), watch the parent directory.
|
# If the path is a file (like a zip file), watch the parent directory.
|
||||||
if path.is_file():
|
if resolved_path.is_file():
|
||||||
yield path.parent
|
yield resolved_path.parent
|
||||||
else:
|
else:
|
||||||
yield path
|
yield resolved_path
|
||||||
|
|
||||||
|
|
||||||
def get_child_arguments():
|
def get_child_arguments():
|
||||||
|
|
Loading…
Reference in New Issue