Skip to content

Commit de98fae

Browse files
committed
Add test case that exercises py312 syntax
1 parent 4d18dd8 commit de98fae

File tree

8 files changed

+45
-0
lines changed

8 files changed

+45
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# gazelle:python_generation_mode file
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
2+
3+
# gazelle:python_generation_mode file
4+
5+
py_library(
6+
name = "_other_module",
7+
srcs = ["_other_module.py"],
8+
visibility = ["//:__subpackages__"],
9+
)
10+
11+
py_binary(
12+
name = "pep_695_type_parameter",
13+
srcs = ["pep_695_type_parameter.py"],
14+
visibility = ["//:__subpackages__"],
15+
deps = [":_other_module"],
16+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# py312 syntax
2+
3+
This test case checks that we properly parse certain python 3.12 syntax, such
4+
as pep 695 type parameters, with go-tree-sitter.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This is a Bazel workspace for the Gazelle test data.

gazelle/python/testdata/py312_syntax/__init__.py

Whitespace-only changes.

gazelle/python/testdata/py312_syntax/_other_module.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def search_one_more_level[T](
2+
graph: dict[T, set[T]], seen: set[T], routes: list[list[T]], target: T
3+
) -> list[T] | None:
4+
"""This function fails to parse with older versions of go-tree-sitter.
5+
6+
Args:
7+
graph: The graph to search as input.
8+
seen: The nodes that have been visited as input/output.
9+
routes: The current routes in the breadth-first search as input/output.
10+
target: The target to search in this extra search level.
11+
12+
Returns:
13+
a route if it ends on the target, or None if no route reaches the
14+
target.
15+
"""
16+
17+
18+
import _other_module
19+
20+
21+
if __name__ == "__main__":
22+
pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---

0 commit comments

Comments
 (0)