Skip to content

test: add test to show walrus operator is supported #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/scip-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- 'Dockerfile.autoindex'

jobs:
release-image:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
27 changes: 27 additions & 0 deletions packages/pyright-scip/snapshots/input/unique/walrus.py
Original file line number Diff line number Diff line change
@@ -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}")
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
113 changes: 113 additions & 0 deletions packages/pyright-scip/snapshots/output/unique/walrus.py
Original file line number Diff line number Diff line change
@@ -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.