Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
I think they turned up due to a pylint tool update.
  • Loading branch information
florianschanda committed May 21, 2024
1 parent 963db41 commit 3188b09
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
4 changes: 4 additions & 0 deletions trlc-lrm-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def token(self):
end_pos = self.lexpos
raw_text = self.fragment[start_pos:end_pos + 1]

# pylint: disable=possibly-used-before-assignment

if kind == "TERMINAL":
t_kind = ""
t_name = None
Expand Down Expand Up @@ -796,6 +798,8 @@ def write_text_object(fd, mh, obj, context, bnf_parser):
assert isinstance(mh, Message_Handler)
assert isinstance(obj, ast.Record_Object)

# pylint: disable=possibly-used-before-assignment

data = obj.to_python_dict()

# Close merged grammar section
Expand Down
34 changes: 19 additions & 15 deletions trlc/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def token(self):
start_pos,
self.lexpos)

# pylint: disable=possibly-used-before-assignment
return Markup_Token(loc,
kind,
self.content[start_pos:self.lexpos + 1])
Expand Down Expand Up @@ -429,13 +430,13 @@ def parse_tuple_field(self,

if optional_required or self.peek_kw("optional"):
self.match_kw("optional")
t_optional = self.ct
if optional_allowed:
field_is_optional = True
else:
t_optional = self.ct
field_is_optional = True
if not optional_allowed:
self.mh.error(self.ct.location, optional_reason)
else:
field_is_optional = False
t_optional = None

# lobster-trace: LRM.Tuple_Field_Types
field_type = self.parse_qualified_name(self.default_scope,
Expand Down Expand Up @@ -541,12 +542,12 @@ def parse_record_component(self, n_record):
assert isinstance(n_record, ast.Record_Type)

c_name, c_descr, t_descr = self.parse_described_name()
t_optional = None
c_optional = False
if self.peek_kw("optional"):
self.match_kw("optional")
t_optional = self.ct
c_optional = True
else:
c_optional = False
c_typ = self.parse_qualified_name(self.default_scope,
ast.Type)
c_typ.set_ast_link(self.ct)
Expand All @@ -561,12 +562,12 @@ def parse_record_component(self, n_record):
self.match("RANGE")
t_range = self.ct
a_loc = self.ct.location
a_hi = None
if self.peek("INTEGER"):
self.match("INTEGER")
a_hi = self.ct.value
elif self.peek("OPERATOR") and self.nt.value == "*":
self.match("OPERATOR")
a_hi = None
else:
self.mh.error(self.nt.location,
"expected INTEGER or * for upper bound")
Expand Down Expand Up @@ -601,19 +602,18 @@ def parse_record_component(self, n_record):
return c_comp

def parse_record_declaration(self):
t_abstract = None
t_final = None
is_abstract = False
is_final = False
if self.peek_kw("abstract"):
self.match_kw("abstract")
t_abstract = self.ct
t_abstract = self.ct
is_abstract = True
is_final = False
elif self.peek_kw("final"):
self.match_kw("final")
t_final = self.ct
is_abstract = False
is_final = True
else:
is_abstract = False
is_final = False
t_final = self.ct
is_final = True

self.match_kw("type")
t_type = self.ct
Expand Down Expand Up @@ -889,6 +889,7 @@ def parse_simple_expression(self, scope):

n_lhs = self.parse_term(scope)
if t_unary:
# pylint: disable=possibly-used-before-assignment
if self.lint_mode and \
isinstance(n_lhs, ast.Binary_Expression) and \
not has_explicit_brackets:
Expand Down Expand Up @@ -1487,6 +1488,9 @@ def parse_check_block(self):
t_message = t_msg,
extrainfo = c_extrainfo)

# pylint: disable=possibly-used-before-assignment
# pylint: disable=used-before-assignment

n_check.set_ast_link(t_first_comma)
if t_severity:
n_check.set_ast_link(t_severity)
Expand Down
1 change: 0 additions & 1 deletion trlc/vcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ def analyze(self):
except Unsupported as exc: # pragma: no cover
self.mh.warning(exc.location,
exc.message)
return

def checks_on_composite_type(self, n_ctyp):
assert isinstance(n_ctyp, Composite_Type)
Expand Down

0 comments on commit 3188b09

Please sign in to comment.