Skip to content

Commit 858822a

Browse files
committed
Removes unnecessary try-except blocks
`resolve_globs` will discard any nonphysical directories so there is no point capturing an exception that will never be thrown
1 parent c0c0dfb commit 858822a

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

fortls/langserver.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,12 +1543,10 @@ def _load_config_file_dirs(self, config_dict: dict) -> None:
15431543
# with glob resolution
15441544
source_dirs = config_dict.get("source_dirs", [])
15451545
for path in source_dirs:
1546-
try:
1547-
dirs = only_dirs(resolve_globs(path, self.root_path))
1548-
self.source_dirs.update(set(dirs))
1549-
except FileNotFoundError as e:
1550-
err = f"Directories input in Configuration file do not exit:\n{e}"
1551-
self.post_message(err, Severity.warn)
1546+
# resolve_globs filters any nonexisting directories so FileNotFoundError
1547+
# found inside only_dirs can never be raised
1548+
dirs = only_dirs(resolve_globs(path, self.root_path))
1549+
self.source_dirs.update(set(dirs))
15521550

15531551
# Keep all directories present in source_dirs but not excl_paths
15541552
self.source_dirs = {i for i in self.source_dirs if i not in self.excl_paths}
@@ -1615,12 +1613,10 @@ def _load_config_file_preproc(self, config_dict: dict) -> None:
16151613
self.pp_defs = {key: "" for key in self.pp_defs}
16161614

16171615
for path in config_dict.get("include_dirs", set()):
1618-
try:
1619-
dirs = only_dirs(resolve_globs(path, self.root_path))
1620-
self.include_dirs.update(set(dirs))
1621-
except FileNotFoundError as e:
1622-
err = f"Directories input in Configuration file do not exit:\n{e}"
1623-
self.post_message(err, Severity.warn)
1616+
# resolve_globs filters any nonexisting directories so FileNotFoundError
1617+
# found inside only_dirs can never be raised
1618+
dirs = only_dirs(resolve_globs(path, self.root_path))
1619+
self.include_dirs.update(set(dirs))
16241620

16251621
def _add_source_dirs(self) -> None:
16261622
"""Will recursively add all subdirectories that contain Fortran

0 commit comments

Comments
 (0)