From 415b1c7091f2673aa97d464fed9172114f2431f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Sat, 10 Oct 2020 10:24:50 +0200 Subject: [PATCH] [WIP] Fix for #334 (directories like 'dir.yaml' + recursive search) Partially reverts a221898 to fix https://github.com/adrienverge/yamllint/issues/334 Linked to https://github.com/cpburnz/python-path-specification/issues/41. --- .gitignore | 2 ++ yamllint/conf/default.yaml | 3 +++ yamllint/config.py | 12 +++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 58d609b..7185533 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ __pycache__ /yamllint.egg-info /build /.eggs +*.yaml +!*.yaml/ diff --git a/yamllint/conf/default.yaml b/yamllint/conf/default.yaml index 0720ded..e0c59b7 100644 --- a/yamllint/conf/default.yaml +++ b/yamllint/conf/default.yaml @@ -2,8 +2,11 @@ yaml-files: - '*.yaml' + - '!*.yaml/' - '*.yml' + - '!*.yml/' - '.yamllint' + - '!.yamllint/' rules: braces: enable diff --git a/yamllint/config.py b/yamllint/config.py index a42e744..ad6848c 100644 --- a/yamllint/config.py +++ b/yamllint/config.py @@ -32,8 +32,14 @@ class YamlLintConfig(object): self.ignore = None - self.yaml_files = pathspec.PathSpec.from_lines( - 'gitwildmatch', ['*.yaml', '*.yml', '.yamllint']) + self.yaml_files = pathspec.PathSpec.from_lines('gitwildmatch', [ + '*.yaml', + '!*.yaml/', + '*.yml', + '!*.yml/', + '.yamllint', + '!.yamllint/', + ]) self.locale = None @@ -48,7 +54,7 @@ class YamlLintConfig(object): return self.ignore and self.ignore.match_file(filepath) def is_yaml_file(self, filepath): - return self.yaml_files.match_file(os.path.basename(filepath)) + return self.yaml_files.match_file(filepath) def enabled_rules(self, filepath): return [yamllint.rules.get(id) for id, val in self.rules.items()