Avoid runtime exception caused by newer pathspec

pull/548/head
Sorin Sbarnea 2 years ago
parent 404656394c
commit 5f60dbae23
No known key found for this signature in database

@ -44,6 +44,11 @@ class SimpleConfigTestCase(unittest.TestCase):
with self.assertRaises(config.YamlLintConfigError): with self.assertRaises(config.YamlLintConfigError):
config.YamlLintConfig('not: valid: yaml') config.YamlLintConfig('not: valid: yaml')
def test_is_file_ignored_allows_none(self):
c = config.YamlLintConfig('ignore: foobar\n')
self.assertTrue(c.is_file_ignored('foobar'))
self.assertFalse(c.is_file_ignored(None))
def test_unknown_rule(self): def test_unknown_rule(self):
with self.assertRaisesRegex( with self.assertRaisesRegex(
config.YamlLintConfigError, config.YamlLintConfigError,

@ -45,7 +45,7 @@ class YamlLintConfig:
self.validate() self.validate()
def is_file_ignored(self, filepath): def is_file_ignored(self, filepath):
return self.ignore and self.ignore.match_file(filepath) return self.ignore and filepath and self.ignore.match_file(filepath)
def is_yaml_file(self, filepath): def is_yaml_file(self, filepath):
return self.yaml_files.match_file(os.path.basename(filepath)) return self.yaml_files.match_file(os.path.basename(filepath))

Loading…
Cancel
Save