From e588c9469fb9ddb399d145a3398a545c107b1119 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 26 Sep 2023 20:50:42 +0200 Subject: [PATCH] fix: fix exclude_files while ignore_dotfiles is disabled (#678) --- ansiblelater/settings.py | 5 +++-- ansiblelater/utils/yamlhelper.py | 6 +++++- docs/content/configuration/_index.md | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ansiblelater/settings.py b/ansiblelater/settings.py index d37ed95..dc1afd9 100644 --- a/ansiblelater/settings.py +++ b/ansiblelater/settings.py @@ -210,9 +210,10 @@ class Settings: excludes = self.config["rules"]["exclude_files"] ignore_dotfiles = self.config["rules"]["ignore_dotfiles"] - if ignore_dotfiles and not self.args_files: + if ignore_dotfiles: excludes.append(".*") - else: + + if self.args_files: del excludes[:] filelist = [] diff --git a/ansiblelater/utils/yamlhelper.py b/ansiblelater/utils/yamlhelper.py index 3807ac2..b4990d2 100644 --- a/ansiblelater/utils/yamlhelper.py +++ b/ansiblelater/utils/yamlhelper.py @@ -537,7 +537,11 @@ def parse_yaml_linenumbers(data, filename): loader.compose_node = compose_node loader.construct_mapping = construct_mapping data = loader.get_single_data() or [] - except (yaml.parser.ParserError, yaml.scanner.ScannerError) as e: + except ( + yaml.parser.ParserError, + yaml.scanner.ScannerError, + yaml.constructor.ConstructorError, + ) as e: raise LaterError("syntax error", e) from e except (yaml.composer.ComposerError) as e: e.problem = f"{e.context} {e.problem}" diff --git a/docs/content/configuration/_index.md b/docs/content/configuration/_index.md index c3ad2c5..49a30f5 100644 --- a/docs/content/configuration/_index.md +++ b/docs/content/configuration/_index.md @@ -13,4 +13,4 @@ Changes can be made in a YAML configuration file or via CLI options, which are p Please note that YAML attributes are overwritten while YAML lists are merged in any configuration files. -To simplify single file linting, e.g. for debugging purposes, ansible-later ignores the `exclude_files` and `ignore_dotfiles` options when only one file is passed to the CLI. +To simplify the linting of individual files, e.g. for debugging purposes, ansible-later ignores the `exclude_files` and `ignore_dotfiles` options when files are passed to the CLI.