diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f3daa41..f975db9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ exclude: tests/(data|__snapshots__|samples) repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -10,7 +10,7 @@ repos: - id: check-added-large-files - repo: https://github.com/PyCQA/pylint - rev: v3.2.7 + rev: v3.3.1 hooks: - id: pylint additional_dependencies: @@ -21,17 +21,17 @@ repos: - "tree-sitter-zeek==0.1.1" - repo: https://github.com/psf/black - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + rev: v3.19.0 hooks: - id: pyupgrade args: ["--py37-plus"] - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.41.0 + rev: v0.42.0 hooks: - id: markdownlint-fix diff --git a/.pylintrc b/.pylintrc index 1498408..533e7ff 100644 --- a/.pylintrc +++ b/.pylintrc @@ -8,4 +8,5 @@ disable= too-many-branches, too-many-instance-attributes, too-many-lines, + too-many-positional-arguments, too-many-statements, diff --git a/pyproject.toml b/pyproject.toml index e720caa..254dc38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,11 +24,11 @@ keywords = [ "parsing", ] -requires-python = ">=3.9" +requires-python = ">= 3.9" dependencies = [ "tree-sitter==0.23.2", - "tree-sitter-zeek==0.1.1", + "tree-sitter-zeek==0.2.1", ] [project.optional-dependencies] diff --git a/tests/__snapshots__/test_samples/test_samples[sample0][testssamplestest1.zeek].raw b/tests/__snapshots__/test_samples/test_samples[sample0][testssamplestest1.zeek].raw index 4cb187a..e82496b 100644 --- a/tests/__snapshots__/test_samples/test_samples[sample0][testssamplestest1.zeek].raw +++ b/tests/__snapshots__/test_samples/test_samples[sample0][testssamplestest1.zeek].raw @@ -206,3 +206,10 @@ function comments() function no_comments() { } + +# Assert. +function foo() + { + assert 1 == 2, "One is not two"; + assert 1 == 1; + } diff --git a/tests/samples/test1.zeek b/tests/samples/test1.zeek index f32711a..bab5999 100644 --- a/tests/samples/test1.zeek +++ b/tests/samples/test1.zeek @@ -173,4 +173,9 @@ function no_comments() { } +# Assert. +function foo() { +assert 1 == 2, "One is not two"; +assert 1 == 1; +} diff --git a/zeekscript/formatter.py b/zeekscript/formatter.py index 48416f1..bbbea2b 100644 --- a/zeekscript/formatter.py +++ b/zeekscript/formatter.py @@ -1027,6 +1027,12 @@ def format(self): self._format_child() # self._write_nl() + elif start_token == "assert": + self._format_child() # 'assert' + self._write_sp() + self._format_children() + self._write_nl() + elif start_token == ";": self._format_child(hints=Hint.NO_LB_BEFORE) # ';' self._write_nl() @@ -1087,6 +1093,10 @@ def format(self): self._format_child(hints=Hint.NO_LB_BEFORE) # ')' +class AssertMsgFormatter(SpaceSeparatedFormatter): + pass + + class ExprFormatter(SpaceSeparatedFormatter, ComplexSequenceFormatterMixin): # Like statments, expressions aren't currently broken into specific symbol # types, so we use helpers or parse into them to identify what particular