From d698ca4390dcaf0090b0c2ff47869edc33d58166 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Wed, 3 May 2023 14:40:02 -0400 Subject: [PATCH] test: add test to show walrus operator is supported --- .github/workflows/scip-docker.yml | 2 +- .../snapshots/input/unique/walrus.py | 27 +++++ .../output/unique/property_access.py | 6 + .../output/unique/vars_inside_scopes.py | 6 + .../snapshots/output/unique/walrus.py | 113 ++++++++++++++++++ 5 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 packages/pyright-scip/snapshots/input/unique/walrus.py create mode 100644 packages/pyright-scip/snapshots/output/unique/walrus.py diff --git a/.github/workflows/scip-docker.yml b/.github/workflows/scip-docker.yml index 9f5613068..dfb630431 100644 --- a/.github/workflows/scip-docker.yml +++ b/.github/workflows/scip-docker.yml @@ -10,7 +10,7 @@ on: - 'Dockerfile.autoindex' jobs: - release-image: + build-image: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/packages/pyright-scip/snapshots/input/unique/walrus.py b/packages/pyright-scip/snapshots/input/unique/walrus.py new file mode 100644 index 000000000..b21d31c65 --- /dev/null +++ b/packages/pyright-scip/snapshots/input/unique/walrus.py @@ -0,0 +1,27 @@ +import re + +some_list = [1, 2, 3, 4, 5, 100, 1000] +pattern = "^[A-Za-z0-9_]*$" +text = "Some_name123" + +# if statement +if (n := len(some_list)) > 10: + print(f"List is too long with {n} elements.") + +if (match := re.search(pattern, text)) is not None: + print("Found match:", match.group(0)) + + +# comprehensions +def show_some_comprehension(): + [print(x, root) for x in some_list if (x % 2 == 0) and (root := x**0.5) > 5] + + +# while loop +while (line := input("Enter text: ")) != "quit": + print(f"You entered: {line}") + + +# if + comprehension +if any((any_n := num) < 0 for num in some_list): + print(f"Negative number found: {any_n}") diff --git a/packages/pyright-scip/snapshots/output/unique/property_access.py b/packages/pyright-scip/snapshots/output/unique/property_access.py index 1db148992..189984d48 100644 --- a/packages/pyright-scip/snapshots/output/unique/property_access.py +++ b/packages/pyright-scip/snapshots/output/unique/property_access.py @@ -84,6 +84,12 @@ def nested(): # > ``` for x in xs: # ^ definition local 0 +# external documentation ```python +# > (function) def len( +# > __obj: Sized, +# > / +# > ) -> int +# > ``` # ^^ reference snapshot-util 0.1 property_access/usage().(xs) print(x.prop_ref) # ^^^^^ reference python-stdlib 3.11 builtins/print(). diff --git a/packages/pyright-scip/snapshots/output/unique/vars_inside_scopes.py b/packages/pyright-scip/snapshots/output/unique/vars_inside_scopes.py index f750116c0..4a2109f4f 100644 --- a/packages/pyright-scip/snapshots/output/unique/vars_inside_scopes.py +++ b/packages/pyright-scip/snapshots/output/unique/vars_inside_scopes.py @@ -57,6 +57,12 @@ def my_func(self): # ^^^^ definition snapshot-util 0.1 vars_inside_scopes/X#my_func().(self) for x in self.items: # ^ definition local 0 +# external documentation ```python +# > (function) def len( +# > __obj: Sized, +# > / +# > ) -> int +# > ``` # ^^^^ reference snapshot-util 0.1 vars_inside_scopes/X#my_func().(self) # ^^^^^ reference snapshot-util 0.1 vars_inside_scopes/X#items. y = x + 1 diff --git a/packages/pyright-scip/snapshots/output/unique/walrus.py b/packages/pyright-scip/snapshots/output/unique/walrus.py new file mode 100644 index 000000000..ea2a6d69b --- /dev/null +++ b/packages/pyright-scip/snapshots/output/unique/walrus.py @@ -0,0 +1,113 @@ +# < definition scip-python python snapshot-util 0.1 walrus/__init__: +#documentation (module) walrus + +import re +# ^^ reference python-stdlib 3.11 re/__init__: + +some_list = [1, 2, 3, 4, 5, 100, 1000] +#^^^^^^^^ definition snapshot-util 0.1 walrus/some_list. +#documentation ```python +# > builtins.list +# > ``` +pattern = "^[A-Za-z0-9_]*$" +#^^^^^^ definition snapshot-util 0.1 walrus/pattern. +#documentation ```python +# > builtins.str +# > ``` +text = "Some_name123" +#^^^ definition snapshot-util 0.1 walrus/text. +#documentation ```python +# > builtins.str +# > ``` + +# if statement +if (n := len(some_list)) > 10: +# ^ definition snapshot-util 0.1 walrus/n. +# ^^^ reference local 0 +# external documentation ```python +# > (function) def len( +# > __obj: Sized, +# > / +# > ) -> int +# > ``` +# ^^^^^^^^^ reference snapshot-util 0.1 walrus/some_list. + print(f"List is too long with {n} elements.") +# ^^^^^ reference python-stdlib 3.11 builtins/print(). +# external documentation ```python +# > (function) def print( +# > *values: object, +# > sep: str | None = " ", +# > end: str | None = "\n", +# > file: SupportsWrite[str] | None = No... +# > flush: Literal[False] = False +# > ) -> None +# > ``` +# ^ reference snapshot-util 0.1 walrus/n. + +if (match := re.search(pattern, text)) is not None: +# ^^^^^ definition snapshot-util 0.1 walrus/match. +# ^^ reference python-stdlib 3.11 re/__init__: +# ^^^^^^ reference python-stdlib 3.11 re/search(). +# ^^^^^^^ reference snapshot-util 0.1 walrus/pattern. +# ^^^^ reference snapshot-util 0.1 walrus/text. + print("Found match:", match.group(0)) +# ^^^^^ reference python-stdlib 3.11 builtins/print(). +# ^^^^^ reference snapshot-util 0.1 walrus/match. +# ^^^^^ reference python-stdlib 3.11 re/Match#group(). + + +# comprehensions +def show_some_comprehension(): +# ^^^^^^^^^^^^^^^^^^^^^^^ definition snapshot-util 0.1 walrus/show_some_comprehension(). +# documentation ```python +# > def show_some_comprehension(): # -> None... +# > ``` + [print(x, root) for x in some_list if (x % 2 == 0) and (root := x**0.5) > 5] +# ^^^^^ reference python-stdlib 3.11 builtins/print(). +# ^ reference local 1 +# ^^^^ reference local 2 +# ^ definition local 1 +# documentation ```python +# > (variable) x: int +# > ``` +# ^^^^^^^^^ reference snapshot-util 0.1 walrus/some_list. +# ^ reference local 1 +# ^^^^ definition local 2 +# ^ reference local 1 + + +# while loop +while (line := input("Enter text: ")) != "quit": +# ^^^^ definition snapshot-util 0.1 walrus/line. +# ^^^^^ reference local 3 +# external documentation ```python +# > (function) def input( +# > __prompt: object = "", +# > / +# > ) -> str +# > ``` + print(f"You entered: {line}") +# ^^^^^ reference python-stdlib 3.11 builtins/print(). +# ^^^^ reference snapshot-util 0.1 walrus/line. + + +# if + comprehension +if any((any_n := num) < 0 for num in some_list): +# ^^^ reference local 4 +# external documentation ```python +# > (function) def any( +# > __iterable: Iterable[object], +# > / +# > ) -> bool +# > ``` +# ^^^^^ definition any_n. +# ^^^ reference local 5 +# ^^^ definition local 5 +# documentation ```python +# > (variable) num: int +# > ``` +# ^^^^^^^^^ reference snapshot-util 0.1 walrus/some_list. + print(f"Negative number found: {any_n}") +# ^^^^^ reference python-stdlib 3.11 builtins/print(). +# ^^^^^ reference any_n. +