Repository: aws-cloudformation/cfn-lint

Issue:
cfnlint via stdin has issues when parameters are present
### CloudFormation Lint Version

v0.70.1

### What operating system are you using?

Mac

### Describe the bug

```sh
echo 'Resources: {}' | cfn-lint --include-checks I              
2022-11-03 11:14:45,106 - cfnlint.decode - ERROR - Template file not found: None
E0000 Template file not found: None
None:1:1
```

when no parameters:
```sh
echo '{"Resources": {}}' | cfn-lint                   
echo $?
0
```

### Expected behavior

```sh
echo 'Resources: {}' | cfn-lint --include-checks I
echo $?
0
```

### Reproduction template

```yaml
Resources: {}
```

```json
{
  "Resources": {}
}
```


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
@@ -677,7 +677,7 @@ def templates(self):
         elif templates_args:
             filenames = templates_args
         else:
-            return None
+            return ['-']
 
         # if only one is specified convert it to array
         if isinstance(filenames, str):
diff --git a/src/cfnlint/decode/cfn_json.py b/src/cfnlint/decode/cfn_json.py
--- a/src/cfnlint/decode/cfn_json.py
+++ b/src/cfnlint/decode/cfn_json.py
@@ -366,8 +366,14 @@ def load(filename):
     content = ''
 
     if not sys.stdin.isatty():
-        for line in fileinput.input(files=filename):
-            content = content + line
+        if sys.version_info.major <= 3 and sys.version_info.minor <= 9:
+            for line in fileinput.input(files=filename):
+                content = content + line
+        else:
+            for line in fileinput.input(  # pylint: disable=unexpected-keyword-arg
+                files=filename, encoding='utf-8'
+            ):
+                content = content + line
     else:
         with open(filename, encoding='utf-8') as fp:
             content = fp.read()
diff --git a/src/cfnlint/decode/cfn_yaml.py b/src/cfnlint/decode/cfn_yaml.py
--- a/src/cfnlint/decode/cfn_yaml.py
+++ b/src/cfnlint/decode/cfn_yaml.py
@@ -256,8 +256,14 @@ def load(filename):
     content = ''
 
     if not sys.stdin.isatty():
-        for line in fileinput.input(files=filename):
-            content = content + line
+        if sys.version_info.major <= 3 and sys.version_info.minor <= 9:
+            for line in fileinput.input(files=filename):
+                content = content + line
+        else:
+            for line in fileinput.input(  # pylint: disable=unexpected-keyword-arg
+                files=filename, encoding='utf-8'
+            ):
+                content = content + line
     else:
         with open(filename, encoding='utf-8') as fp:
             content = fp.read()


Test patch:
diff --git a/test/unit/module/core/test_run_cli.py b/test/unit/module/core/test_run_cli.py
--- a/test/unit/module/core/test_run_cli.py
+++ b/test/unit/module/core/test_run_cli.py
@@ -108,7 +108,7 @@ def test_template_via_stdin(self):
 
         with patch('sys.stdin', StringIO(file_content)):
             (_, filenames, _) = cfnlint.core.get_args_filenames([])
-            assert filenames == [None]
+            assert filenames == ['-'], filenames
 
         with patch('sys.stdin', StringIO(file_content)):
             (_, filenames, _) = cfnlint.core.get_args_filenames(['--template', filename])