Skip to content

Commit a6fa2f1

Browse files
authored
Use the property attributes for Mark (#2821)
1 parent 70059ee commit a6fa2f1

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

src/cfnlint/decode/cfn_json.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from json.scanner import NUMBER_RE
1616

1717
import cfnlint
18+
from cfnlint.decode.mark import Mark
1819
from cfnlint.decode.node import dict_node, list_node, str_node, sub_node
1920

2021
LOGGER = logging.getLogger(__name__)
@@ -117,17 +118,6 @@ def build_match_from_key(message, key):
117118
)
118119

119120

120-
class Mark:
121-
"""Mark of line and column"""
122-
123-
line = 1
124-
column = 1
125-
126-
def __init__(self, line, column):
127-
self.line = line
128-
self.column = column
129-
130-
131121
# pylint: disable=W0102
132122
# Exception based on builtin Python Function
133123
def py_scanstring(s, end, strict=True, _b=BACKSLASH, _m=STRINGCHUNK.match):

src/cfnlint/decode/mark.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: MIT-0
4+
"""
5+
6+
7+
class Mark:
8+
"""Mark of line and column"""
9+
10+
line = 1
11+
column = 1
12+
13+
def __init__(self, line, column):
14+
self.line = line
15+
self.column = column

src/cfnlint/decode/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
SPDX-License-Identifier: MIT-0
44
"""
55

6+
from cfnlint.decode.mark import Mark
67
from cfnlint.decode.node import dict_node, list_node, str_node
78

89

9-
def convert_dict(template, start_mark=(0, 0), end_mark=(0, 0)):
10+
def convert_dict(template, start_mark=Mark(0, 0), end_mark=Mark(0, 0)):
1011
"""Convert dict to template"""
1112
if isinstance(template, dict):
1213
if not isinstance(template, dict_node):

src/cfnlint/template/transforms/_language_extensions.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ def language_extension(cfn: Any) -> TransformResult:
5454

5555
message = "Error transforming template: {0}"
5656
if hasattr(e.key, "start_mark"):
57-
sm_line = e.key.start_mark[0] + 1
58-
sm_column = e.key.start_mark[1] + 1
57+
sm_line = e.key.start_mark.line + 1
58+
sm_column = e.key.start_mark.column + 1
5959
else:
6060
sm_line = 1
6161
sm_column = 1
6262
if hasattr(e.key, "end_mark"):
63-
em_line = e.key.end_mark[0] + 1
64-
em_column = e.key.end_mark[1] + 1
63+
em_line = e.key.end_mark.line + 1
64+
em_column = e.key.end_mark.column + 1
6565
else:
6666
em_line = 1
6767
em_column = 1

0 commit comments

Comments
 (0)