-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds enclosing ranges to function and class definitions (#132)
Co-authored-by: Varun Gandhi <[email protected]>
- Loading branch information
1 parent
f5e9aee
commit 1572f2f
Showing
53 changed files
with
568 additions
and
611 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
packages/pyright-scip/snapshots/input/builtin_imports/builtin_imports.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# format-options: showDocs | ||
|
||
import re | ||
from typing import Callable, Optional | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
packages/pyright-scip/snapshots/input/class_nohint/class_nohint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# format-options: showDocs | ||
|
||
class Example: | ||
# Note, only y has a type hint | ||
y: int | ||
|
13 changes: 13 additions & 0 deletions
13
packages/pyright-scip/snapshots/input/enclosing_range_class/advanced.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# format-options: showRanges | ||
def class_decorator(cls): | ||
def wrapper(*args, **kwargs): | ||
return cls(*args, **kwargs) | ||
return wrapper | ||
|
||
@class_decorator | ||
class Test: | ||
def __init__(self, x: float): | ||
self.x = x | ||
|
||
def test(self) -> float: | ||
return self.x |
3 changes: 3 additions & 0 deletions
3
packages/pyright-scip/snapshots/input/enclosing_range_class/simple.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# format-options: showRanges | ||
class Test(): | ||
pass |
11 changes: 11 additions & 0 deletions
11
packages/pyright-scip/snapshots/input/enclosing_range_function/advanced.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# format-options: showRanges | ||
def decorator(func): | ||
def wrapper(*args, **kwargs): | ||
return func(*args, **kwargs) | ||
return wrapper | ||
|
||
@decorator | ||
def func(x: float) -> float: | ||
test = x | ||
|
||
return test |
3 changes: 3 additions & 0 deletions
3
packages/pyright-scip/snapshots/input/enclosing_range_function/simple.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# format-options: showRanges | ||
def simple(x): | ||
return x |
2 changes: 2 additions & 0 deletions
2
packages/pyright-scip/snapshots/input/unique/field_docstring.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# format-options: showDocs | ||
|
||
class ClassWithField: | ||
|
||
a: int | ||
|
2 changes: 2 additions & 0 deletions
2
packages/pyright-scip/snapshots/input/unique/inferred_field_docstring.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# format-options: showDocs | ||
|
||
class ClassWithInferredField: | ||
def __init__(self, b: int): | ||
self.b = b |
2 changes: 2 additions & 0 deletions
2
packages/pyright-scip/snapshots/input/unique/module_docstring.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# format-options: showDocs | ||
|
||
""" | ||
This is a docstring for this module | ||
""" | ||
|
13 changes: 0 additions & 13 deletions
13
packages/pyright-scip/snapshots/output/aliased_import/actual.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
# < definition scip-python python snapshot-util 0.1 actual/__init__: | ||
#documentation (module) actual | ||
|
||
import aliased | ||
# ^^^^^^^ reference snapshot-util 0.1 aliased/__init__: | ||
import aliased as A | ||
# ^^^^^^^ reference snapshot-util 0.1 aliased/__init__: | ||
# ^ reference local 0 | ||
# documentation ```python | ||
# > (module) A | ||
# > ``` | ||
|
||
print(A.SOME_CONSTANT) | ||
#^^^^ 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 local 0 | ||
# ^^^^^^^^^^^^^ reference snapshot-util 0.1 aliased/SOME_CONSTANT. | ||
|
4 changes: 0 additions & 4 deletions
4
packages/pyright-scip/snapshots/output/aliased_import/aliased.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
# < definition scip-python python snapshot-util 0.1 aliased/__init__: | ||
#documentation (module) aliased | ||
|
||
SOME_CONSTANT = "Some Constant" | ||
#^^^^^^^^^^^^ definition snapshot-util 0.1 aliased/SOME_CONSTANT. | ||
#documentation ```python | ||
# > builtins.str | ||
# > ``` | ||
|
2 changes: 2 additions & 0 deletions
2
packages/pyright-scip/snapshots/output/builtin_imports/builtin_imports.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/pyright-scip/snapshots/output/class_nohint/class_nohint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
packages/pyright-scip/snapshots/output/comprehensions/comp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
packages/pyright-scip/snapshots/output/dunder_vars/__main__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,9 @@ | ||
# < definition scip-python python snapshot-util 0.1 __main__/__init__: | ||
#documentation (module) __main__ | ||
|
||
|
||
if __name__ == '__main__': | ||
# ^^^^^^^^ reference python-stdlib 3.11 builtins/__name__# | ||
# external documentation ```python | ||
# > __name__: str | ||
# > ``` | ||
print("main") | ||
# ^^^^^ 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 | ||
# > ``` | ||
|
||
|
4 changes: 0 additions & 4 deletions
4
packages/pyright-scip/snapshots/output/empty_project_name_version/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/pyright-scip/snapshots/output/enclosing_range_class/advanced.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# < definition scip-python python snapshot-util 0.1 advanced/__init__: | ||
|
||
# format-options: showRanges | ||
# < start enclosing_range scip-python python snapshot-util 0.1 advanced/class_decorator(). | ||
def class_decorator(cls): | ||
# ^^^^^^^^^^^^^^^ definition snapshot-util 0.1 advanced/class_decorator(). | ||
# ^^^ definition snapshot-util 0.1 advanced/class_decorator().(cls) | ||
# ⌄ start enclosing_range scip-python python snapshot-util 0.1 advanced/class_decorator().wrapper(). | ||
def wrapper(*args, **kwargs): | ||
# ^^^^^^^ definition snapshot-util 0.1 advanced/class_decorator().wrapper(). | ||
# ^^^^ definition snapshot-util 0.1 advanced/class_decorator().wrapper().(args) | ||
# ^^^^^^ definition snapshot-util 0.1 advanced/class_decorator().wrapper().(kwargs) | ||
return cls(*args, **kwargs) | ||
# ^^^ reference snapshot-util 0.1 advanced/class_decorator().(cls) | ||
# ^^^^ reference snapshot-util 0.1 advanced/class_decorator().wrapper().(args) | ||
# ^^^^^^ reference snapshot-util 0.1 advanced/class_decorator().wrapper().(kwargs) | ||
# ^ end enclosing_range scip-python python snapshot-util 0.1 advanced/class_decorator().wrapper(). | ||
return wrapper | ||
# ^^^^^^^ reference snapshot-util 0.1 advanced/class_decorator().wrapper(). | ||
# < end enclosing_range scip-python python snapshot-util 0.1 advanced/class_decorator(). | ||
|
||
# < start enclosing_range scip-python python snapshot-util 0.1 advanced/Test# | ||
@class_decorator | ||
#^^^^^^^^^^^^^^^ reference snapshot-util 0.1 advanced/class_decorator(). | ||
class Test: | ||
# ^^^^ definition snapshot-util 0.1 advanced/Test# | ||
# ⌄ start enclosing_range scip-python python snapshot-util 0.1 advanced/Test#__init__(). | ||
def __init__(self, x: float): | ||
# ^^^^^^^^ definition snapshot-util 0.1 advanced/Test#__init__(). | ||
# ^^^^ definition snapshot-util 0.1 advanced/Test#__init__().(self) | ||
# ^ definition snapshot-util 0.1 advanced/Test#__init__().(x) | ||
# ^^^^^ reference python-stdlib 3.11 builtins/float# | ||
self.x = x | ||
# ^^^^ reference snapshot-util 0.1 advanced/Test#__init__().(self) | ||
# ^ definition snapshot-util 0.1 advanced/Test#x. | ||
# ^ reference snapshot-util 0.1 advanced/Test#__init__().(x) | ||
# ^ end enclosing_range scip-python python snapshot-util 0.1 advanced/Test#__init__(). | ||
|
||
# ⌄ start enclosing_range scip-python python snapshot-util 0.1 advanced/Test#test(). | ||
def test(self) -> float: | ||
# ^^^^ definition snapshot-util 0.1 advanced/Test#test(). | ||
# ^^^^ definition snapshot-util 0.1 advanced/Test#test().(self) | ||
# ^^^^^ reference python-stdlib 3.11 builtins/float# | ||
return self.x | ||
# ^^^^ reference snapshot-util 0.1 advanced/Test#test().(self) | ||
# ^ reference snapshot-util 0.1 advanced/Test#x. | ||
# ^ end enclosing_range scip-python python snapshot-util 0.1 advanced/Test#test(). | ||
# < end enclosing_range scip-python python snapshot-util 0.1 advanced/Test# | ||
|
9 changes: 9 additions & 0 deletions
9
packages/pyright-scip/snapshots/output/enclosing_range_class/simple.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# < definition scip-python python snapshot-util 0.1 simple/__init__: | ||
|
||
# format-options: showRanges | ||
# < start enclosing_range scip-python python snapshot-util 0.1 simple/Test# | ||
class Test(): | ||
# ^^^^ definition snapshot-util 0.1 simple/Test# | ||
pass | ||
# < end enclosing_range scip-python python snapshot-util 0.1 simple/Test# | ||
|
37 changes: 37 additions & 0 deletions
37
packages/pyright-scip/snapshots/output/enclosing_range_function/advanced.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# < definition scip-python python snapshot-util 0.1 advanced/__init__: | ||
|
||
# format-options: showRanges | ||
# < start enclosing_range scip-python python snapshot-util 0.1 advanced/decorator(). | ||
def decorator(func): | ||
# ^^^^^^^^^ definition snapshot-util 0.1 advanced/decorator(). | ||
# ^^^^ definition snapshot-util 0.1 advanced/decorator().(func) | ||
# ⌄ start enclosing_range scip-python python snapshot-util 0.1 advanced/decorator().wrapper(). | ||
def wrapper(*args, **kwargs): | ||
# ^^^^^^^ definition snapshot-util 0.1 advanced/decorator().wrapper(). | ||
# ^^^^ definition snapshot-util 0.1 advanced/decorator().wrapper().(args) | ||
# ^^^^^^ definition snapshot-util 0.1 advanced/decorator().wrapper().(kwargs) | ||
return func(*args, **kwargs) | ||
# ^^^^ reference snapshot-util 0.1 advanced/decorator().(func) | ||
# ^^^^ reference snapshot-util 0.1 advanced/decorator().wrapper().(args) | ||
# ^^^^^^ reference snapshot-util 0.1 advanced/decorator().wrapper().(kwargs) | ||
# ^ end enclosing_range scip-python python snapshot-util 0.1 advanced/decorator().wrapper(). | ||
return wrapper | ||
# ^^^^^^^ reference snapshot-util 0.1 advanced/decorator().wrapper(). | ||
# < end enclosing_range scip-python python snapshot-util 0.1 advanced/decorator(). | ||
|
||
# < start enclosing_range scip-python python snapshot-util 0.1 advanced/func(). | ||
@decorator | ||
#^^^^^^^^^ reference snapshot-util 0.1 advanced/decorator(). | ||
def func(x: float) -> float: | ||
# ^^^^ definition snapshot-util 0.1 advanced/func(). | ||
# ^ definition snapshot-util 0.1 advanced/func().(x) | ||
# ^^^^^ reference python-stdlib 3.11 builtins/float# | ||
# ^^^^^ reference python-stdlib 3.11 builtins/float# | ||
test = x | ||
# ^^^^ definition local 0 | ||
# ^ reference snapshot-util 0.1 advanced/func().(x) | ||
|
||
return test | ||
# ^^^^ reference local 0 | ||
# < end enclosing_range scip-python python snapshot-util 0.1 advanced/func(). | ||
|
11 changes: 11 additions & 0 deletions
11
packages/pyright-scip/snapshots/output/enclosing_range_function/simple.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# < definition scip-python python snapshot-util 0.1 simple/__init__: | ||
|
||
# format-options: showRanges | ||
# < start enclosing_range scip-python python snapshot-util 0.1 simple/simple(). | ||
def simple(x): | ||
# ^^^^^^ definition snapshot-util 0.1 simple/simple(). | ||
# ^ definition snapshot-util 0.1 simple/simple().(x) | ||
return x | ||
# ^ reference snapshot-util 0.1 simple/simple().(x) | ||
# < end enclosing_range scip-python python snapshot-util 0.1 simple/simple(). | ||
|
13 changes: 0 additions & 13 deletions
13
packages/pyright-scip/snapshots/output/f_string/fstring.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,9 @@ | ||
# < definition scip-python python snapshot-util 0.1 fstring/__init__: | ||
#documentation (module) fstring | ||
|
||
var = ", world!" | ||
#^^ definition snapshot-util 0.1 fstring/var. | ||
#documentation ```python | ||
# > builtins.str | ||
# > ``` | ||
|
||
print(f"var: hello {var}") | ||
#^^^^ 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 fstring/var. | ||
|
10 changes: 0 additions & 10 deletions
10
packages/pyright-scip/snapshots/output/file_from_module_import/abc/file.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,11 @@ | ||
# < definition scip-python python snapshot-util 0.1 `abc.file`/__init__: | ||
#documentation (module) abc.file | ||
|
||
from xyz import nested_file | ||
# ^^^ reference snapshot-util 0.1 xyz/__init__: | ||
# ^^^^^^^^^^^ reference snapshot-util 0.1 `xyz.nested_file`/__init__: | ||
|
||
print(nested_file.X) | ||
#^^^^ 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 `xyz.nested_file`/__init__: | ||
# ^ reference snapshot-util 0.1 `xyz.nested_file`/X. | ||
|
Oops, something went wrong.