Skip to content

Commit 599e9bc

Browse files
[pylint.message] Add a location attribute to 'pylint.Message'
1 parent e2652e7 commit 599e9bc

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

pylint/message/message.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,16 @@ def format(self, template: str) -> str:
7777
cf. https://docs.python.org/2/library/string.html#formatstrings
7878
"""
7979
return template.format(**asdict(self))
80+
81+
@property
82+
def location(self) -> MessageLocationTuple:
83+
return MessageLocationTuple(
84+
self.abspath,
85+
self.path,
86+
self.module,
87+
self.obj,
88+
self.line,
89+
self.column,
90+
self.end_line,
91+
self.end_column,
92+
)

tests/message/unittest_message.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,7 @@ def build_message(
5555
)
5656
e1234 = build_message(e1234_message_definition, e1234_location_values)
5757
w1234 = build_message(w1234_message_definition, w1234_location_values)
58+
assert e1234.location == e1234_location_values
59+
assert w1234.location == w1234_location_values
5860
assert e1234.format(template) == expected
5961
assert w1234.format(template) == "8:11:12: W1234: message (msg-symbol)"

0 commit comments

Comments
 (0)