Repository: aws-cloudformation/cfn-lint

Issue:
AttributeError: 'PosixPath' object has no attribute 'read_text'
*cfn-lint version:*
0.9.x & 0.11.x

*Description of issue.*
When running `cfn-lint -c I -t <path to template.yml> -a <path to rules>` with a .cfnlintrc file, I receive the error from here:
https://github.com/awslabs/cfn-python-lint/blob/master/src/cfnlint/config.py#L211

*Please provide as much information as possible:*
When running `cfn-lint -c I -t <path to template.yml> -a <path to rules>` with a .cfnlintrc file in my root of my workspace, I get the following error:
```
  File "/REDACTED/cfnlint/config.py", line 211, in _read_config line 211, in _read_config
    config_template = yaml.safe_load(config.read_text())
AttributeError: 'PosixPath' object has no attribute 'read_text'
```
I believe read_text is not supported until Python 3.5.3 per some other Github Issues I saw on this in other repos.

Looking into the code-coverage looks like that line is not covered which is why its not failing the build - https://codecov.io/gh/awslabs/cfn-python-lint/src/master/src/cfnlint/config.py#L211


Discussion:

Resolving patch:
diff --git a/src/cfnlint/config.py b/src/cfnlint/config.py
--- a/src/cfnlint/config.py
+++ b/src/cfnlint/config.py
@@ -21,8 +21,8 @@
 import json
 import os
 import six
-import yaml
 import jsonschema
+import cfnlint.decode.cfn_yaml
 from cfnlint.version import __version__
 try:  # pragma: no cover
     from pathlib import Path
@@ -208,7 +208,7 @@ def _read_config(self, config):
 
         if self._has_file(config):
             LOGGER.debug('Parsing CFNLINTRC')
-            config_template = yaml.safe_load(config.read_text())
+            config_template = cfnlint.decode.cfn_yaml.load(str(config))
 
         if not config_template:
             config_template = {}


Test patch:
diff --git a/test/fixtures/configs/cfnlintrc_read.yaml b/test/fixtures/configs/cfnlintrc_read.yaml
new file mode 100644
--- /dev/null
+++ b/test/fixtures/configs/cfnlintrc_read.yaml
@@ -0,0 +1,4 @@
+templates:
+- test/fixtures/templates/good/**/*.yaml
+include_checks:
+- I
diff --git a/test/module/config/test_config_file_args.py b/test/module/config/test_config_file_args.py
--- a/test/module/config/test_config_file_args.py
+++ b/test/module/config/test_config_file_args.py
@@ -19,6 +19,10 @@
 import jsonschema
 import cfnlint.config  # pylint: disable=E0401
 from testlib.testcase import BaseTestCase
+try:  # pragma: no cover
+    from pathlib import Path
+except ImportError:  # pragma: no cover
+    from pathlib2 import Path
 
 
 LOGGER = logging.getLogger('cfnlint')
@@ -31,6 +35,20 @@ def tearDown(self):
         for handler in LOGGER.handlers:
             LOGGER.removeHandler(handler)
 
+    def test_config_parser_read_config(self):
+        """ Testing one file successful """
+        # cfnlintrc_mock.return_value.side_effect = [Mock(return_value=True), Mock(return_value=False)]
+        config = cfnlint.config.ConfigFileArgs()
+        config_file = Path('test/fixtures/configs/cfnlintrc_read.yaml')
+        config_template = config._read_config(config_file)
+        self.assertEqual(
+            config_template,
+            {
+                'templates': ['test/fixtures/templates/good/**/*.yaml'],
+                'include_checks': ['I']
+            }
+        )
+
     @patch('cfnlint.config.ConfigFileArgs._read_config', create=True)
     def test_config_parser_read(self, yaml_mock):
         """ Testing one file successful """