Skip to content

Commit

Permalink
[lint] add the C4 set to fuff
Browse files Browse the repository at this point in the history
  • Loading branch information
apalala committed Nov 10, 2023
1 parent f310828 commit b27fb5f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
line-length = 88

select = ['F', 'E', 'W', 'UP', 'I', 'YTT', 'S', 'B', 'COM']
select = ['F', 'E', 'W', 'UP', 'I', 'YTT', 'S', 'B', 'COM', 'C4']
ignore = [
'E501', 'E741', 'E402',
'S101', 'S102', 'S105', 'S301', 'S311',
'C408',
]
exclude = ['tatsu/bootstrap.py']

Expand Down
2 changes: 1 addition & 1 deletion tatsu/codegen/objectmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _find_renderer_class(self, node):
class Rule(ModelRenderer):
def render_fields(self, fields):
defs = [safe_name(d) for d, _ in compress_seq(self.defines())]
defs = list(sorted(set(defs)))
defs = sorted(set(defs))
spec = fields["spec"]

kwargs = '\n'.join('%s: Any = None' % d for d in defs)
Expand Down
4 changes: 2 additions & 2 deletions tatsu/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def _memoization(self):
return self.memoize_lookaheads or self._lookahead == 0

def _rulestack(self):
rulestack = map(lambda r: r.name, reversed(self._rule_stack))
rulestack = [r.name for r in reversed(self._rule_stack)]
stack = self.trace_separator.join(rulestack)
if max(len(s) for s in stack.splitlines()) > self.trace_length:
stack = stack[:self.trace_length]
Expand Down Expand Up @@ -537,7 +537,7 @@ def _trace_match(self, token, name=None, failed=False):
)

def _make_exception(self, item, exclass=FailedParse):
rulestack = list(map(lambda r: r.name, self._rule_stack))
rulestack = [r.name for r in self._rule_stack]
return exclass(self.tokenizer, rulestack, item)

def _error(self, item, exclass=FailedParse):
Expand Down
2 changes: 1 addition & 1 deletion tatsu/grammars.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ def __init__(self, name, rules, /, config: ParserConfig|None = None, directives:

missing = self.missing_rules(oset(r.name for r in self.rules))
if missing:
msg = '\n'.join([''] + list(sorted(missing)))
msg = '\n'.join([''] + sorted(missing))
raise GrammarError('Unknown rules, no parser generated:' + msg)

self._calc_lookahead_sets()
Expand Down
4 changes: 2 additions & 2 deletions tatsu/infos.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ class LineIndexInfo(NamedTuple):

@staticmethod
def block_index(name, n):
return list(
return [
LineIndexInfo(line, i)
for line, i in zip(n * [name], range(n), strict=False)
)
]


class LineInfo(NamedTuple):
Expand Down
6 changes: 3 additions & 3 deletions tatsu/symtables.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def line_index(self, include_entries=False, include_references=False):
result.update(index)
assert isinstance(result, set)
assert all(isinstance(i, LineIndexInfo) for i in result)
return list(sorted(result))
return sorted(result)

def reference_line_index(self):
result = set()
Expand All @@ -250,11 +250,11 @@ def __repr__(self):
return '%s[]' % self.name

def __json__(self, seen=None):
return dict([
return dict(
('node', type(self.node).__name__),
('entries', super().__json__(seen=seen)),
('references', asjson(self._references, seen=seen)),
])
)

def __getstate__(self):
state = self.__dict__.copy()
Expand Down

0 comments on commit b27fb5f

Please sign in to comment.