Skip to content

Commit

Permalink
feat: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Oct 9, 2023
1 parent b8bca19 commit 9a42907
Show file tree
Hide file tree
Showing 37 changed files with 720 additions and 610 deletions.
33 changes: 20 additions & 13 deletions bolt/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"create_bolt_root_parser",
"create_bolt_command_parser",
"UndefinedIdentifier",
"UndefinedIdentifierErrorHandler",
"ImprovedErrorHandler",
"BranchScopeManager",
"FinalExpressionParser",
"InterpolationParser",
Expand Down Expand Up @@ -97,7 +97,14 @@
normalize_whitespace,
string_to_number,
)
from tokenstream import InvalidSyntax, Token, TokenStream, set_location
from tokenstream import (
InvalidSyntax,
Token,
TokenStream,
UnexpectedEOF,
UnexpectedToken,
set_location,
)

from .ast import (
AstAssignment,
Expand Down Expand Up @@ -178,7 +185,6 @@
LexicalScope,
MacroScope,
ProcMacroScope,
UnboundLocalIdentifier,
UndefinedIdentifier,
)
from .utils import internal
Expand Down Expand Up @@ -211,6 +217,7 @@ def get_bolt_parsers(
macro_handler=macro_handler,
),
"nested_root": create_bolt_root_parser(parsers["nested_root"], macro_handler),
"root_item": ImprovedErrorHandler(parsers["root_item"]),
"command": create_bolt_command_parser(macro_handler, modules, bolt_prototypes),
"command:argument:bolt:if_block": delegate("bolt:if_block"),
"command:argument:bolt:elif_condition": delegate("bolt:elif_condition"),
Expand Down Expand Up @@ -662,14 +669,13 @@ def create_bolt_command_parser(
parser = MemoHandler(parser)
parser = BindingStorageHandler(parser)
parser = ImportStatementHandler(parser, modules)
parser = UndefinedIdentifierErrorHandler(parser)
parser = SubcommandConstraint(parser, command_identifiers=bolt_prototypes)
return parser


@dataclass
class UndefinedIdentifierErrorHandler:
"""Parser that provides hints for errors involving undefined identifiers."""
class ImprovedErrorHandler:
"""Parser that tries to recover more specific error alternatives."""

parser: Parser

Expand All @@ -678,13 +684,14 @@ def __call__(self, stream: TokenStream) -> Any:
return self.parser(stream)
except UndefinedIdentifier:
raise
except InvalidSyntax as exc:
alts = list(exc.alternatives.get(UnboundLocalIdentifier, []))
alts += exc.alternatives.get(UndefinedIdentifier, [])
for alt in alts:
if alt.end_location.pos + 1 >= exc.location.pos: # kind of a cheat
alt.notes.append(str(exc))
raise alt from None
except (UnexpectedToken, UnexpectedEOF) as exc:
for exc_type, alts in exc.alternatives.items():
if not issubclass(exc_type, (UnexpectedToken, UnexpectedEOF)):
for alt in alts:
if alt.end_location.pos + 1 >= exc.location.pos:
if isinstance(alt, UndefinedIdentifier):
alt.notes.append(str(exc))
raise alt from None
raise


Expand Down
1,102 changes: 556 additions & 546 deletions poetry.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ include = ["bolt/py.typed"]

[tool.poetry.dependencies]
python = "^3.10"
beet = ">=0.87.0"
mecha = ">=0.74.0"
beet = ">=0.95.4"
mecha = ">=0.78.1"

[tool.poetry.group.dev.dependencies]
pytest = "^7.3.1"
black = "^23.3.0"
pytest = "^7.4.2"
black = "^23.9.1"
isort = "^5.12.0"
python-semantic-release = "^7.33.3"
pytest-insta = "^0.2.0"
lectern = ">=0.26.0"
lectern = ">=0.29.0"

[tool.poetry.plugins.beet]
commands = "bolt.commands"
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/bolt__parse_212__0.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#>ERROR Expected bracket '[', curly '{', docstring, ellipsis, false, identifier or 5 other tokens but got invalid ':'.
#>ERROR Expected bracket '[', curly '{', docstring, ellipsis, false, identifier or 8 other tokens but got invalid ':'.
# line 1, column 5
# 1 | with:
# : ^
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/bolt__parse_230__0.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
macro foo:
pass
#>ERROR Expected colon, literal 'advancement', literal 'align', literal 'anchored', literal 'append', literal 'as' or 135 other tokens but got literal 'foo'.
#>ERROR Expected colon, literal 'advancement', literal 'align', literal 'anchored', literal 'append', literal 'as' or 144 other tokens but got literal 'foo'.
# line 3, column 7
# 2 | pass
# 3 | as @p foo
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/bolt__parse_277__0.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#>ERROR Expected literal 'day', literal 'midnight', literal 'night', literal 'noon' or time but got literal 'hex.time'.
#>ERROR Expected call expression on builtin "hex".
# line 1, column 10
# 1 | time set hex.time
# : ^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/bolt__parse_48__0.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1 * 2
#>ERROR Expected bracket '[', curly '{', decorator, docstring, ellipsis, false or 166 other tokens but got literal '*'.
#>ERROR Expected bracket '[', curly '{', decorator, docstring, ellipsis, false or 174 other tokens but got literal '*'.
# line 2, column 1
# 1 | 1 * 2
# 2 | * 3
Expand Down
2 changes: 2 additions & 0 deletions tests/snapshots/bolt__parse_86__0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
# line 1, column 8
# 1 | return foo
# : ^^^
# Notes:
# - Expected eof, newline or number but got literal 'foo'.
return foo
2 changes: 1 addition & 1 deletion tests/snapshots/bolt__parse_99__0.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#>ERROR Expected colon, literal 'advancement', literal 'align', literal 'anchored', literal 'append', literal 'as' or 135 other tokens but got literal 'for'.
#>ERROR Expected colon, literal 'advancement', literal 'align', literal 'anchored', literal 'append', literal 'as' or 144 other tokens but got literal 'for'.
# line 1, column 7
# 1 | at @s for i in "foo":
# : ^^^
Expand Down
15 changes: 1 addition & 14 deletions tests/snapshots/examples__build_bolt_1_20__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 14,
"pack_format": 18,
"description": ""
}
}
Expand All @@ -30,16 +30,3 @@ return 0
```mcfunction
return 42
```

## Resource pack

`@resource_pack pack.mcmeta`

```json
{
"pack": {
"pack_format": 14,
"description": ""
}
}
```
4 changes: 2 additions & 2 deletions tests/snapshots/examples__build_bolt_basic__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down Expand Up @@ -643,7 +643,7 @@ say json loaded!
```json
{
"pack": {
"pack_format": 13,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_chicken__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_circular__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_class__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_debug__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_defer__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_docstring__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_flat__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_generated__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_lazy__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_macro__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_macro_perf__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_memo__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_merge__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_nesting__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_order__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_prelude__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_proc_macro__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/examples__build_bolt_sample_ui__0.pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
```json
{
"pack": {
"pack_format": 12,
"pack_format": 18,
"description": ""
}
}
Expand Down
Loading

0 comments on commit 9a42907

Please sign in to comment.