Skip to content

Commit

Permalink
Merge branch 'topic/bbannier/assert'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Nov 22, 2024
2 parents 4536280 + 90860f4 commit 0971a7e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/PyCQA/pylint
rev: v3.2.7
rev: v3.3.1
hooks:
- id: pylint
additional_dependencies:
Expand All @@ -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
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ disable=
too-many-branches,
too-many-instance-attributes,
too-many-lines,
too-many-positional-arguments,
too-many-statements,
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,10 @@ function comments()

function no_comments()
{ }

# Assert.
function foo()
{
assert 1 == 2, "One is not two";
assert 1 == 1;
}
5 changes: 5 additions & 0 deletions tests/samples/test1.zeek
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,9 @@ function no_comments()
{
}

# Assert.
function foo() {
assert 1 == 2, "One is not two";
assert 1 == 1;
}

10 changes: 10 additions & 0 deletions zeekscript/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,12 @@ def format(self):
self._format_child() # <preproc_directive>
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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0971a7e

Please sign in to comment.