Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
"Topic :: Software Development :: Testing",
]
dependencies = [
"pathspec >= 0.5.3",
"pathspec >= 1.0.3",
"pyyaml",
]
dynamic = ["version"]
Expand Down
30 changes: 14 additions & 16 deletions yamllint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def __init__(self, content=None, file=None):

self.ignore = None

self.yaml_files = pathspec.PathSpec.from_lines(
'gitwildmatch', ['*.yaml', '*.yml', '.yamllint'])
self.yaml_files = pathspec.GitIgnoreSpec.from_lines(
['*.yaml', '*.yml', '.yamllint'])

self.locale = None

Expand Down Expand Up @@ -112,18 +112,17 @@ def parse(self, raw_content):
raise YamlLintConfigError(
'invalid config: ignore-from-file should contain '
'filename(s), either as a list or string')
self.ignore = pathspec.PathSpec.from_lines(
'gitwildmatch',
self.ignore = pathspec.GitIgnoreSpec.from_lines(
decoder.lines_in_files(conf['ignore-from-file'])
)
elif 'ignore' in conf:
if isinstance(conf['ignore'], str):
self.ignore = pathspec.PathSpec.from_lines(
'gitwildmatch', conf['ignore'].splitlines())
self.ignore = pathspec.GitIgnoreSpec.from_lines(
conf['ignore'].splitlines())
elif (isinstance(conf['ignore'], list) and
all(isinstance(line, str) for line in conf['ignore'])):
self.ignore = pathspec.PathSpec.from_lines(
'gitwildmatch', conf['ignore'])
self.ignore = pathspec.GitIgnoreSpec.from_lines(
conf['ignore'])
else:
raise YamlLintConfigError(
'invalid config: ignore should contain file patterns')
Expand All @@ -134,8 +133,8 @@ def parse(self, raw_content):
raise YamlLintConfigError(
'invalid config: yaml-files '
'should be a list of file patterns')
self.yaml_files = pathspec.PathSpec.from_lines('gitwildmatch',
conf['yaml-files'])
self.yaml_files = pathspec.GitIgnoreSpec.from_lines(
conf['yaml-files'])

if 'locale' in conf:
if not isinstance(conf['locale'], str):
Expand Down Expand Up @@ -168,19 +167,18 @@ def validate_rule_conf(rule, conf):
raise YamlLintConfigError(
'invalid config: ignore-from-file should contain '
'valid filename(s), either as a list or string')
conf['ignore'] = pathspec.PathSpec.from_lines(
'gitwildmatch',
conf['ignore'] = pathspec.GitIgnoreSpec.from_lines(
decoder.lines_in_files(conf['ignore-from-file'])
)
elif ('ignore' in conf and not isinstance(
conf['ignore'], pathspec.pathspec.PathSpec)):
if isinstance(conf['ignore'], str):
conf['ignore'] = pathspec.PathSpec.from_lines(
'gitwildmatch', conf['ignore'].splitlines())
conf['ignore'] = pathspec.GitIgnoreSpec.from_lines(
conf['ignore'].splitlines())
elif (isinstance(conf['ignore'], list) and
all(isinstance(line, str) for line in conf['ignore'])):
conf['ignore'] = pathspec.PathSpec.from_lines(
'gitwildmatch', conf['ignore'])
conf['ignore'] = pathspec.GitIgnoreSpec.from_lines(
conf['ignore'])
else:
raise YamlLintConfigError(
'invalid config: ignore should contain file patterns')
Expand Down