aboutsummaryrefslogtreecommitdiff
path: root/scripts/qapi/source.py
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2021-05-19 14:39:39 -0400
committerMarkus Armbruster <armbru@redhat.com>2021-05-20 11:28:27 +0200
commitb2b31fdf9bc66a82718c9e6ede2f364b0005728a (patch)
treec2bd8ecea4a4536e35000ae291c64290c5ddae0a /scripts/qapi/source.py
parent334c3cd58a202d082703a1ae175b4230f4157f65 (diff)
qapi/source: Remove line number from QAPISourceInfo initializer
With the QAPISourceInfo(None, None, None) construct gone, there's no longer any reason to have to specify that a file starts on the first line. Remove it from the initializer and default it to 1. Remove the last vestiges where we check for 'line' being unset, that can't happen, now. Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210519183951.3946870-4-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'scripts/qapi/source.py')
-rw-r--r--scripts/qapi/source.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/scripts/qapi/source.py b/scripts/qapi/source.py
index 1ade864d7b..04193cc964 100644
--- a/scripts/qapi/source.py
+++ b/scripts/qapi/source.py
@@ -31,10 +31,9 @@ class QAPISchemaPragma:
class QAPISourceInfo:
T = TypeVar('T', bound='QAPISourceInfo')
- def __init__(self, fname: str, line: int,
- parent: Optional['QAPISourceInfo']):
+ def __init__(self, fname: str, parent: Optional['QAPISourceInfo']):
self.fname = fname
- self.line = line
+ self.line = 1
self.parent = parent
self.pragma: QAPISchemaPragma = (
parent.pragma if parent else QAPISchemaPragma()
@@ -52,10 +51,7 @@ class QAPISourceInfo:
return info
def loc(self) -> str:
- ret = self.fname
- if self.line is not None:
- ret += ':%d' % self.line
- return ret
+ return f"{self.fname}:{self.line}"
def in_defn(self) -> str:
if self.defn_name: