diff --git a/packages/pyright-scip/snapshots/input/builtin_imports/builtin_imports.py b/packages/pyright-scip/snapshots/input/builtin_imports/builtin_imports.py index a37b6eb3d..b6bea9e79 100644 --- a/packages/pyright-scip/snapshots/input/builtin_imports/builtin_imports.py +++ b/packages/pyright-scip/snapshots/input/builtin_imports/builtin_imports.py @@ -1,3 +1,5 @@ +# format-options: showDocs + import re from typing import Callable, Optional diff --git a/packages/pyright-scip/snapshots/input/class_nohint/class_nohint.py b/packages/pyright-scip/snapshots/input/class_nohint/class_nohint.py index 138b53db7..8ae5ca882 100644 --- a/packages/pyright-scip/snapshots/input/class_nohint/class_nohint.py +++ b/packages/pyright-scip/snapshots/input/class_nohint/class_nohint.py @@ -1,3 +1,5 @@ +# format-options: showDocs + class Example: # Note, only y has a type hint y: int diff --git a/packages/pyright-scip/snapshots/input/enclosing_range_class/advanced.py b/packages/pyright-scip/snapshots/input/enclosing_range_class/advanced.py new file mode 100644 index 000000000..abdc18fcb --- /dev/null +++ b/packages/pyright-scip/snapshots/input/enclosing_range_class/advanced.py @@ -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 diff --git a/packages/pyright-scip/snapshots/input/enclosing_range_class/simple.py b/packages/pyright-scip/snapshots/input/enclosing_range_class/simple.py new file mode 100644 index 000000000..26746956e --- /dev/null +++ b/packages/pyright-scip/snapshots/input/enclosing_range_class/simple.py @@ -0,0 +1,3 @@ +# format-options: showRanges +class Test(): + pass diff --git a/packages/pyright-scip/snapshots/input/enclosing_range_function/advanced.py b/packages/pyright-scip/snapshots/input/enclosing_range_function/advanced.py new file mode 100644 index 000000000..5eff95e69 --- /dev/null +++ b/packages/pyright-scip/snapshots/input/enclosing_range_function/advanced.py @@ -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 diff --git a/packages/pyright-scip/snapshots/input/enclosing_range_function/simple.py b/packages/pyright-scip/snapshots/input/enclosing_range_function/simple.py new file mode 100644 index 000000000..3bededc3b --- /dev/null +++ b/packages/pyright-scip/snapshots/input/enclosing_range_function/simple.py @@ -0,0 +1,3 @@ +# format-options: showRanges +def simple(x): + return x diff --git a/packages/pyright-scip/snapshots/input/unique/field_docstring.py b/packages/pyright-scip/snapshots/input/unique/field_docstring.py index 748245af0..e7bd35227 100644 --- a/packages/pyright-scip/snapshots/input/unique/field_docstring.py +++ b/packages/pyright-scip/snapshots/input/unique/field_docstring.py @@ -1,3 +1,5 @@ +# format-options: showDocs + class ClassWithField: a: int diff --git a/packages/pyright-scip/snapshots/input/unique/inferred_field_docstring.py b/packages/pyright-scip/snapshots/input/unique/inferred_field_docstring.py index e0ad5150c..e1471fd57 100644 --- a/packages/pyright-scip/snapshots/input/unique/inferred_field_docstring.py +++ b/packages/pyright-scip/snapshots/input/unique/inferred_field_docstring.py @@ -1,3 +1,5 @@ +# format-options: showDocs + class ClassWithInferredField: def __init__(self, b: int): self.b = b diff --git a/packages/pyright-scip/snapshots/input/unique/module_docstring.py b/packages/pyright-scip/snapshots/input/unique/module_docstring.py index 3f210648a..5d8a1ee20 100644 --- a/packages/pyright-scip/snapshots/input/unique/module_docstring.py +++ b/packages/pyright-scip/snapshots/input/unique/module_docstring.py @@ -1,3 +1,5 @@ +# format-options: showDocs + """ This is a docstring for this module """ diff --git a/packages/pyright-scip/snapshots/output/aliased_import/actual.py b/packages/pyright-scip/snapshots/output/aliased_import/actual.py index a6253ac5f..3829699fd 100644 --- a/packages/pyright-scip/snapshots/output/aliased_import/actual.py +++ b/packages/pyright-scip/snapshots/output/aliased_import/actual.py @@ -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. diff --git a/packages/pyright-scip/snapshots/output/aliased_import/aliased.py b/packages/pyright-scip/snapshots/output/aliased_import/aliased.py index 50ec12315..4335bc015 100644 --- a/packages/pyright-scip/snapshots/output/aliased_import/aliased.py +++ b/packages/pyright-scip/snapshots/output/aliased_import/aliased.py @@ -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 -# > ``` diff --git a/packages/pyright-scip/snapshots/output/builtin_imports/builtin_imports.py b/packages/pyright-scip/snapshots/output/builtin_imports/builtin_imports.py index e14550560..184fd3056 100644 --- a/packages/pyright-scip/snapshots/output/builtin_imports/builtin_imports.py +++ b/packages/pyright-scip/snapshots/output/builtin_imports/builtin_imports.py @@ -1,6 +1,8 @@ # < definition scip-python python snapshot-util 0.1 builtin_imports/__init__: #documentation (module) builtin_imports +# format-options: showDocs + import re # ^^ reference python-stdlib 3.11 re/__init__: from typing import Callable, Optional diff --git a/packages/pyright-scip/snapshots/output/class_nohint/class_nohint.py b/packages/pyright-scip/snapshots/output/class_nohint/class_nohint.py index 7cec6c45e..74564ec3e 100644 --- a/packages/pyright-scip/snapshots/output/class_nohint/class_nohint.py +++ b/packages/pyright-scip/snapshots/output/class_nohint/class_nohint.py @@ -1,6 +1,8 @@ # < definition scip-python python snapshot-util 0.1 class_nohint/__init__: #documentation (module) class_nohint +# format-options: showDocs + class Example: # ^^^^^^^ definition snapshot-util 0.1 class_nohint/Example# # documentation ```python diff --git a/packages/pyright-scip/snapshots/output/comprehensions/comp.py b/packages/pyright-scip/snapshots/output/comprehensions/comp.py index ab89f8f67..9ac3b8261 100644 --- a/packages/pyright-scip/snapshots/output/comprehensions/comp.py +++ b/packages/pyright-scip/snapshots/output/comprehensions/comp.py @@ -1,13 +1,7 @@ # < definition scip-python python snapshot-util 0.1 comp/__init__: -#documentation (module) comp def something(x): # ^^^^^^^^^ definition snapshot-util 0.1 comp/something(). -# documentation ```python -# > def something( -# > x -# > ): -# > ``` # ^ definition snapshot-util 0.1 comp/something().(x) return 2 * x # ^ reference snapshot-util 0.1 comp/something().(x) @@ -15,76 +9,34 @@ def something(x): _ = [x for x in "should be local 0"] # ^ reference local 0 # ^ definition local 0 -# documentation ```python -# > (variable) x: str -# > ``` _ = [something(x) for x in "should be local 1"] # ^^^^^^^^^ reference snapshot-util 0.1 comp/something(). # ^ reference local 1 # ^ definition local 1 -# documentation ```python -# > (variable) x: str -# > ``` _ = [something(x) for x in "should be local 2" if x == "s"] # ^^^^^^^^^ reference snapshot-util 0.1 comp/something(). # ^ reference local 2 # ^ definition local 2 -# documentation ```python -# > (variable) x: str -# > ``` # ^ reference local 2 _ = {k: x for (k, x) in enumerate(range(10))} # ^ reference local 3 # ^ reference local 4 # ^ definition local 3 -# documentation ```python -# > (variable) k: int -# > ``` # ^ definition local 4 -# documentation ```python -# > (variable) x: int -# > ``` # ^^^^^^^^^ reference python-stdlib 3.11 builtins/enumerate# -# external documentation ```python -# > class enumerate( -# > iterable: Iterable[int], -# > start: int = ... -# > ) -# > ``` # ^^^^^ reference python-stdlib 3.11 builtins/range# -# external documentation ```python -# > class range( -# > __stop: SupportsIndex, -# > / -# > ) -# > ``` asdf = (var for var in [1, 2, 3] if var % 2 == 0) #^^^ definition snapshot-util 0.1 comp/asdf. -#documentation ```python -# > typing.Generator -# > ``` # ^^^ reference local 5 # ^^^ definition local 5 -# documentation ```python -# > (variable) var: int -# > ``` # ^^^ reference local 5 for var in asdf: # ^^^ definition snapshot-util 0.1 comp/var. # ^^^^ reference snapshot-util 0.1 comp/asdf. print(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 comp/var. # TODO: ListComprehensions with if diff --git a/packages/pyright-scip/snapshots/output/dunder_vars/__main__.py b/packages/pyright-scip/snapshots/output/dunder_vars/__main__.py index ffcdc2677..27a5e1120 100644 --- a/packages/pyright-scip/snapshots/output/dunder_vars/__main__.py +++ b/packages/pyright-scip/snapshots/output/dunder_vars/__main__.py @@ -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 -# > ``` diff --git a/packages/pyright-scip/snapshots/output/empty_project_name_version/main.py b/packages/pyright-scip/snapshots/output/empty_project_name_version/main.py index 69cfd8736..a6e76749f 100644 --- a/packages/pyright-scip/snapshots/output/empty_project_name_version/main.py +++ b/packages/pyright-scip/snapshots/output/empty_project_name_version/main.py @@ -1,11 +1,7 @@ # < definition scip-python python . . main/__init__: -#documentation (module) main def main(): # ^^^^ definition . . main/main(). -# documentation ```python -# > def main(): # -> None: -# > ``` pass main() diff --git a/packages/pyright-scip/snapshots/output/enclosing_range_class/advanced.py b/packages/pyright-scip/snapshots/output/enclosing_range_class/advanced.py new file mode 100644 index 000000000..d535119a7 --- /dev/null +++ b/packages/pyright-scip/snapshots/output/enclosing_range_class/advanced.py @@ -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# + diff --git a/packages/pyright-scip/snapshots/output/enclosing_range_class/simple.py b/packages/pyright-scip/snapshots/output/enclosing_range_class/simple.py new file mode 100644 index 000000000..71a71c002 --- /dev/null +++ b/packages/pyright-scip/snapshots/output/enclosing_range_class/simple.py @@ -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# + diff --git a/packages/pyright-scip/snapshots/output/enclosing_range_function/advanced.py b/packages/pyright-scip/snapshots/output/enclosing_range_function/advanced.py new file mode 100644 index 000000000..44d7aecdb --- /dev/null +++ b/packages/pyright-scip/snapshots/output/enclosing_range_function/advanced.py @@ -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(). + diff --git a/packages/pyright-scip/snapshots/output/enclosing_range_function/simple.py b/packages/pyright-scip/snapshots/output/enclosing_range_function/simple.py new file mode 100644 index 000000000..fe80f65e2 --- /dev/null +++ b/packages/pyright-scip/snapshots/output/enclosing_range_function/simple.py @@ -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(). + diff --git a/packages/pyright-scip/snapshots/output/f_string/fstring.py b/packages/pyright-scip/snapshots/output/f_string/fstring.py index a40594ee7..a66718401 100644 --- a/packages/pyright-scip/snapshots/output/f_string/fstring.py +++ b/packages/pyright-scip/snapshots/output/f_string/fstring.py @@ -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. diff --git a/packages/pyright-scip/snapshots/output/file_from_module_import/abc/file.py b/packages/pyright-scip/snapshots/output/file_from_module_import/abc/file.py index 4da5f0c4d..6def7404c 100644 --- a/packages/pyright-scip/snapshots/output/file_from_module_import/abc/file.py +++ b/packages/pyright-scip/snapshots/output/file_from_module_import/abc/file.py @@ -1,5 +1,4 @@ # < 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__: @@ -7,15 +6,6 @@ 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. diff --git a/packages/pyright-scip/snapshots/output/file_from_module_import/file_from_module.py b/packages/pyright-scip/snapshots/output/file_from_module_import/file_from_module.py index f9e22416b..ad305892e 100644 --- a/packages/pyright-scip/snapshots/output/file_from_module_import/file_from_module.py +++ b/packages/pyright-scip/snapshots/output/file_from_module_import/file_from_module.py @@ -1,5 +1,4 @@ # < definition scip-python python snapshot-util 0.1 file_from_module/__init__: -#documentation (module) file_from_module from xyz import nested_file # ^^^ reference snapshot-util 0.1 xyz/__init__: @@ -7,15 +6,6 @@ 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. diff --git a/packages/pyright-scip/snapshots/output/file_from_module_import/xyz/__init__.py b/packages/pyright-scip/snapshots/output/file_from_module_import/xyz/__init__.py index 44e89b298..25308027e 100644 --- a/packages/pyright-scip/snapshots/output/file_from_module_import/xyz/__init__.py +++ b/packages/pyright-scip/snapshots/output/file_from_module_import/xyz/__init__.py @@ -1,4 +1,3 @@ # < definition scip-python python snapshot-util 0.1 xyz/__init__: -#documentation (module) xyz diff --git a/packages/pyright-scip/snapshots/output/file_from_module_import/xyz/nested_file.py b/packages/pyright-scip/snapshots/output/file_from_module_import/xyz/nested_file.py index 5ab3021d7..62f17e5b7 100644 --- a/packages/pyright-scip/snapshots/output/file_from_module_import/xyz/nested_file.py +++ b/packages/pyright-scip/snapshots/output/file_from_module_import/xyz/nested_file.py @@ -1,9 +1,5 @@ # < definition scip-python python snapshot-util 0.1 `xyz.nested_file`/__init__: -#documentation (module) xyz.nested_file X = "a constant" # definition snapshot-util 0.1 `xyz.nested_file`/X. -#documentation ```python -# > builtins.str -# > ``` diff --git a/packages/pyright-scip/snapshots/output/nameparts_import/nameparts.py b/packages/pyright-scip/snapshots/output/nameparts_import/nameparts.py index ae1223cc5..e748aae63 100644 --- a/packages/pyright-scip/snapshots/output/nameparts_import/nameparts.py +++ b/packages/pyright-scip/snapshots/output/nameparts_import/nameparts.py @@ -1,5 +1,4 @@ # < definition scip-python python snapshot-util 0.1 nameparts/__init__: -#documentation (module) nameparts import importlib.resources # ^^^^^^^^^^^^^^^^^^^ reference python-stdlib 3.11 `importlib.resources`/__init__: @@ -7,14 +6,6 @@ importlib.resources.read_text('pre_commit.resources', 'filename') #^^^^^^^^^^^^^^^^^^ reference python-stdlib 3.11 `importlib.resources`/__init__: # ^^^^^^^^^ reference local 0 -# documentation ```python -# > def read_text( -# > package: Package, -# > resource: Resource, -# > encoding: str = "utf-8", -# > errors: str = "strict" -# > ) -> str: -# > ``` importlib.resources.read_text('pre_commit.resources', 'filename') #^^^^^^^^ reference python-stdlib 3.11 `importlib.resources`/__init__: # ^^^^^^^^^ reference local 0 diff --git a/packages/pyright-scip/snapshots/output/nested_items/src/__init__.py b/packages/pyright-scip/snapshots/output/nested_items/src/__init__.py index 4cd70ced8..00291ef7a 100644 --- a/packages/pyright-scip/snapshots/output/nested_items/src/__init__.py +++ b/packages/pyright-scip/snapshots/output/nested_items/src/__init__.py @@ -1,4 +1,3 @@ # < definition scip-python python snapshot-util 0.1 src/__init__: -#documentation (module) src diff --git a/packages/pyright-scip/snapshots/output/nested_items/src/foo/__init__.py b/packages/pyright-scip/snapshots/output/nested_items/src/foo/__init__.py index 5f6716acd..39b336df6 100644 --- a/packages/pyright-scip/snapshots/output/nested_items/src/foo/__init__.py +++ b/packages/pyright-scip/snapshots/output/nested_items/src/foo/__init__.py @@ -1,4 +1,3 @@ # < definition scip-python python snapshot-util 0.1 `src.foo`/__init__: -#documentation (module) src.foo diff --git a/packages/pyright-scip/snapshots/output/nested_items/src/foo/bar/__init__.py b/packages/pyright-scip/snapshots/output/nested_items/src/foo/bar/__init__.py index 7b4b21e25..29a739c24 100644 --- a/packages/pyright-scip/snapshots/output/nested_items/src/foo/bar/__init__.py +++ b/packages/pyright-scip/snapshots/output/nested_items/src/foo/bar/__init__.py @@ -1,14 +1,7 @@ # < definition scip-python python snapshot-util 0.1 `src.foo.bar`/__init__: -#documentation (module) src.foo.bar class InitClass: # ^^^^^^^^^ definition snapshot-util 0.1 `src.foo.bar`/InitClass# -# documentation ```python -# > class InitClass: -# > ``` init_item = 10 # ^^^^^^^^^ definition snapshot-util 0.1 `src.foo.bar`/InitClass#init_item. -# documentation ```python -# > builtins.int -# > ``` diff --git a/packages/pyright-scip/snapshots/output/nested_items/src/foo/bar/baz/mod.py b/packages/pyright-scip/snapshots/output/nested_items/src/foo/bar/baz/mod.py index c0c2c66d5..2d8362c12 100644 --- a/packages/pyright-scip/snapshots/output/nested_items/src/foo/bar/baz/mod.py +++ b/packages/pyright-scip/snapshots/output/nested_items/src/foo/bar/baz/mod.py @@ -1,30 +1,14 @@ # < definition scip-python python snapshot-util 0.1 `src.foo.bar.baz.mod`/__init__: -#documentation (module) src.foo.bar.baz.mod class SuchNestedMuchWow: # ^^^^^^^^^^^^^^^^^ definition snapshot-util 0.1 `src.foo.bar.baz.mod`/SuchNestedMuchWow# -# documentation ```python -# > class SuchNestedMuchWow: -# > ``` class_item: int = 42 # ^^^^^^^^^^ definition snapshot-util 0.1 `src.foo.bar.baz.mod`/SuchNestedMuchWow#class_item. -# documentation ```python -# > (variable) class_item: Literal[42] -# > ``` # ^^^ reference python-stdlib 3.11 builtins/int# -# external documentation ```python -# > (class) int -# > ``` class AnotherNestedMuchWow: # ^^^^^^^^^^^^^^^^^^^^ definition snapshot-util 0.1 `src.foo.bar.baz.mod`/AnotherNestedMuchWow# -# documentation ```python -# > class AnotherNestedMuchWow: -# > ``` other_item: int = 42 # ^^^^^^^^^^ definition snapshot-util 0.1 `src.foo.bar.baz.mod`/AnotherNestedMuchWow#other_item. -# documentation ```python -# > (variable) other_item: Literal[42] -# > ``` # ^^^ reference python-stdlib 3.11 builtins/int# diff --git a/packages/pyright-scip/snapshots/output/nested_items/src/importer.py b/packages/pyright-scip/snapshots/output/nested_items/src/importer.py index cd90cbb8b..998268aaf 100644 --- a/packages/pyright-scip/snapshots/output/nested_items/src/importer.py +++ b/packages/pyright-scip/snapshots/output/nested_items/src/importer.py @@ -1,5 +1,4 @@ # < definition scip-python python snapshot-util 0.1 `src.importer`/__init__: -#documentation (module) src.importer from foo.bar import InitClass # ^^^^^^^ reference snapshot-util 0.1 `foo.bar`/__init__: @@ -11,15 +10,6 @@ print(SuchNestedMuchWow().class_item) #^^^^ 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 `src.foo.bar.baz.mod`/SuchNestedMuchWow# # ^^^^^^^^^^ reference snapshot-util 0.1 `src.foo.bar.baz.mod`/SuchNestedMuchWow#class_item. print(AnotherNestedMuchWow().other_item) diff --git a/packages/pyright-scip/snapshots/output/nested_items/src/long_importer.py b/packages/pyright-scip/snapshots/output/nested_items/src/long_importer.py index bc76513e4..c945fde00 100644 --- a/packages/pyright-scip/snapshots/output/nested_items/src/long_importer.py +++ b/packages/pyright-scip/snapshots/output/nested_items/src/long_importer.py @@ -1,20 +1,10 @@ # < definition scip-python python snapshot-util 0.1 `src.long_importer`/__init__: -#documentation (module) src.long_importer import foo.bar.baz.mod # ^^^^^^^^^^^^^^^ reference snapshot-util 0.1 `foo.bar.baz.mod`/__init__: print(foo.bar.baz.mod.SuchNestedMuchWow) #^^^^ 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 `foo.bar.baz.mod`/__init__: # ^^^^^^^^^^^^^^^^^ reference snapshot-util 0.1 `src.foo.bar.baz.mod`/SuchNestedMuchWow# diff --git a/packages/pyright-scip/snapshots/output/odd_pkg_name_1/main.py b/packages/pyright-scip/snapshots/output/odd_pkg_name_1/main.py index 4baa23eeb..e732449a4 100644 --- a/packages/pyright-scip/snapshots/output/odd_pkg_name_1/main.py +++ b/packages/pyright-scip/snapshots/output/odd_pkg_name_1/main.py @@ -1,11 +1,7 @@ # < definition scip-python python package with space 0.1 main/__init__: -#documentation (module) main def main(): # ^^^^ definition package with space 0.1 main/main(). -# documentation ```python -# > def main(): # -> None: -# > ``` pass main() diff --git a/packages/pyright-scip/snapshots/output/pyproject_1/main.py b/packages/pyright-scip/snapshots/output/pyproject_1/main.py index 45eff829e..eb2e64294 100644 --- a/packages/pyright-scip/snapshots/output/pyproject_1/main.py +++ b/packages/pyright-scip/snapshots/output/pyproject_1/main.py @@ -1,11 +1,7 @@ # < definition scip-python python abc 16.05 main/__init__: -#documentation (module) main def main(): # ^^^^ definition abc 16.05 main/main(). -# documentation ```python -# > def main(): # -> None: -# > ``` pass main() diff --git a/packages/pyright-scip/snapshots/output/relative_import/bar.py b/packages/pyright-scip/snapshots/output/relative_import/bar.py index 2f48cc291..2dc2f5f07 100644 --- a/packages/pyright-scip/snapshots/output/relative_import/bar.py +++ b/packages/pyright-scip/snapshots/output/relative_import/bar.py @@ -1,5 +1,4 @@ # < definition scip-python python snapshot-util 0.1 bar/__init__: -#documentation (module) bar from .foo import exported_function # ^^^^ reference snapshot-util 0.1 foo/__init__: diff --git a/packages/pyright-scip/snapshots/output/relative_import/foo.py b/packages/pyright-scip/snapshots/output/relative_import/foo.py index 250b49800..3bbb6c733 100644 --- a/packages/pyright-scip/snapshots/output/relative_import/foo.py +++ b/packages/pyright-scip/snapshots/output/relative_import/foo.py @@ -1,45 +1,24 @@ # < definition scip-python python snapshot-util 0.1 foo/__init__: -#documentation (module) foo def exported_function(): # ^^^^^^^^^^^^^^^^^ definition snapshot-util 0.1 foo/exported_function(). -# documentation ```python -# > def exported_function(): # -> Literal['f... -# > ``` return "function" class MyClass: # ^^^^^^^ definition snapshot-util 0.1 foo/MyClass# -# documentation ```python -# > class MyClass: -# > ``` -# documentation This is a class and it is cool """This is a class and it is cool""" def __init__(self): # ^^^^^^^^ definition snapshot-util 0.1 foo/MyClass#__init__(). -# documentation ```python -# > def __init__( -# > self -# > ) -> None: -# > ``` # ^^^^ definition snapshot-util 0.1 foo/MyClass#__init__().(self) pass def exported_function(self): # ^^^^^^^^^^^^^^^^^ definition snapshot-util 0.1 foo/MyClass#exported_function(). -# documentation ```python -# > def exported_function( -# > self -# > ): # -> Literal['exported']: -# > ``` # ^^^^ definition snapshot-util 0.1 foo/MyClass#exported_function().(self) return "exported" this_class = MyClass() #^^^^^^^^^ definition snapshot-util 0.1 foo/this_class. -#documentation ```python -# > foo.MyClass -# > ``` # ^^^^^^^ reference snapshot-util 0.1 foo/MyClass# diff --git a/packages/pyright-scip/snapshots/output/request_goofiness/goofy.py b/packages/pyright-scip/snapshots/output/request_goofiness/goofy.py index 2306e980e..ace8ab824 100644 --- a/packages/pyright-scip/snapshots/output/request_goofiness/goofy.py +++ b/packages/pyright-scip/snapshots/output/request_goofiness/goofy.py @@ -1,20 +1,10 @@ # < definition scip-python python snapshot-util 0.1 goofy/__init__: -#documentation (module) goofy import requests # ^^^^^^^^ reference requests 2.0.0 requests/__init__: print(requests.get("https://sourcegraph.com")) #^^^^ 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 requests 2.0.0 requests/__init__: # ^^^ reference requests 2.0.0 `requests.api`/get(). diff --git a/packages/pyright-scip/snapshots/output/single_class/src/single_class.py b/packages/pyright-scip/snapshots/output/single_class/src/single_class.py index 35b12aa7c..7192c173e 100644 --- a/packages/pyright-scip/snapshots/output/single_class/src/single_class.py +++ b/packages/pyright-scip/snapshots/output/single_class/src/single_class.py @@ -1,51 +1,22 @@ # < definition scip-python python snapshot-util 0.1 `src.single_class`/__init__: -#documentation (module) src.single_class class ExampleClass: # ^^^^^^^^^^^^ definition snapshot-util 0.1 `src.single_class`/ExampleClass# -# documentation ```python -# > class ExampleClass: -# > ``` a: int # ^ definition snapshot-util 0.1 `src.single_class`/ExampleClass#a. -# documentation ```python -# > (variable) a: int -# > ``` # ^^^ reference python-stdlib 3.11 builtins/int# -# external documentation ```python -# > (class) int -# > ``` b: int # ^ definition snapshot-util 0.1 `src.single_class`/ExampleClass#b. -# documentation ```python -# > (variable) b: int -# > ``` # ^^^ reference python-stdlib 3.11 builtins/int# c: str # ^ definition snapshot-util 0.1 `src.single_class`/ExampleClass#c. -# documentation ```python -# > (variable) c: str -# > ``` # ^^^ reference python-stdlib 3.11 builtins/str# -# external documentation ```python -# > (class) str -# > ``` static_var = "Hello World" # ^^^^^^^^^^ definition snapshot-util 0.1 `src.single_class`/ExampleClass#static_var. -# documentation ```python -# > builtins.str -# > ``` def __init__(self, a: int, b: int): # ^^^^^^^^ definition snapshot-util 0.1 `src.single_class`/ExampleClass#__init__(). -# documentation ```python -# > def __init__( -# > self, -# > a: int, -# > b: int -# > ) -> None: -# > ``` # ^^^^ definition snapshot-util 0.1 `src.single_class`/ExampleClass#__init__().(self) # ^ definition snapshot-util 0.1 `src.single_class`/ExampleClass#__init__().(a) # ^^^ reference python-stdlib 3.11 builtins/int# @@ -53,9 +24,6 @@ def __init__(self, a: int, b: int): # ^^^ reference python-stdlib 3.11 builtins/int# local_c = ", world!" # ^^^^^^^ definition local 0 -# documentation ```python -# > builtins.str -# > ``` self.a = a # ^^^^ reference snapshot-util 0.1 `src.single_class`/ExampleClass#__init__().(self) diff --git a/packages/pyright-scip/snapshots/output/single_function/src/single_function.py b/packages/pyright-scip/snapshots/output/single_function/src/single_function.py index 812f1e362..d8b46e233 100644 --- a/packages/pyright-scip/snapshots/output/single_function/src/single_function.py +++ b/packages/pyright-scip/snapshots/output/single_function/src/single_function.py @@ -1,42 +1,22 @@ # < definition scip-python python snapshot-util 0.1 `src.single_function`/__init__: -#documentation (module) src.single_function def my_cool_function(a: str) -> str: # ^^^^^^^^^^^^^^^^ definition snapshot-util 0.1 `src.single_function`/my_cool_function(). -# documentation ```python -# > def my_cool_function( -# > a: str -# > ) -> str: -# > ``` # ^ definition snapshot-util 0.1 `src.single_function`/my_cool_function().(a) # ^^^ reference python-stdlib 3.11 builtins/str# -# external documentation ```python -# > (class) str -# > ``` # ^^^ reference python-stdlib 3.11 builtins/str# x = ", world" # ^ definition local 0 -# documentation ```python -# > builtins.str -# > ``` return a + x # ^ reference snapshot-util 0.1 `src.single_function`/my_cool_function().(a) # ^ reference local 0 def my_cool_function_2(a: str): # ^^^^^^^^^^^^^^^^^^ definition snapshot-util 0.1 `src.single_function`/my_cool_function_2(). -# documentation ```python -# > def my_cool_function_2( -# > a: str -# > ): -# > ``` # ^ definition snapshot-util 0.1 `src.single_function`/my_cool_function_2().(a) # ^^^ reference python-stdlib 3.11 builtins/str# x = ", world" # ^ definition local 1 -# documentation ```python -# > builtins.str -# > ``` return (lambda y: a + x + y)("oh no") # ^ definition local 2(y) # ^ reference snapshot-util 0.1 `src.single_function`/my_cool_function_2().(a) @@ -45,9 +25,6 @@ def my_cool_function_2(a: str): def next_level(): # ^^^^^^^^^^ definition snapshot-util 0.1 `src.single_function`/next_level(). -# documentation ```python -# > def next_level(): # -> (a: str) -> str: -# > ``` return my_cool_function # ^^^^^^^^^^^^^^^^ reference snapshot-util 0.1 `src.single_function`/my_cool_function(). diff --git a/packages/pyright-scip/snapshots/output/unique/builtin_import_refs.py b/packages/pyright-scip/snapshots/output/unique/builtin_import_refs.py index 39a77a9e2..24c04ff8c 100644 --- a/packages/pyright-scip/snapshots/output/unique/builtin_import_refs.py +++ b/packages/pyright-scip/snapshots/output/unique/builtin_import_refs.py @@ -1,46 +1,10 @@ # < definition scip-python python snapshot-util 0.1 builtin_import_refs/__init__: -#documentation (module) builtin_import_refs from typing import Any # ^^^^^^ reference python-stdlib 3.11 typing/__init__: -# external documentation ```python -# > (module) typing -# > ``` -# external documentation --- -# > -# external documentation The typing module: Support for gradual t... -# > -# > At large scale, the structure of the mod... -# > * Imports and exports, all public names... -# > * Internal helper functions: these shou... -# > * \_SpecialForm and its instances (spec... -# > Any, NoReturn, ClassVar, Union, Optional... -# > * Classes whose instances can be type a... -# > ForwardRef, TypeVar and ParamSpec -# > * The core of internal generics API: \_... -# > currently only used by Tuple and Callabl... -# > etc., are instances of either of these c... -# > * The public counterpart of the generic... -# > * Public helper functions: get\_type\_h... -# > no\_type\_check\_decorator. -# > * Generic aliases for collections.abc A... -# > * Special types: NewType, NamedTuple, T... -# > * Wrapper submodules for re and io rela... # ^^^ reference python-stdlib 3.11 typing/Any. -# external documentation ```python -# > (variable) Any: Any -# > ``` print(Any) #^^^^ 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 python-stdlib 3.11 typing/Any. diff --git a/packages/pyright-scip/snapshots/output/unique/field_docstring.py b/packages/pyright-scip/snapshots/output/unique/field_docstring.py index 0be01ab7e..6e3ef6406 100644 --- a/packages/pyright-scip/snapshots/output/unique/field_docstring.py +++ b/packages/pyright-scip/snapshots/output/unique/field_docstring.py @@ -1,6 +1,8 @@ # < definition scip-python python snapshot-util 0.1 field_docstring/__init__: #documentation (module) field_docstring +# format-options: showDocs + class ClassWithField: # ^^^^^^^^^^^^^^ definition snapshot-util 0.1 field_docstring/ClassWithField# # documentation ```python diff --git a/packages/pyright-scip/snapshots/output/unique/grandparent_impl.py b/packages/pyright-scip/snapshots/output/unique/grandparent_impl.py index a932a6d4b..adbd07ead 100644 --- a/packages/pyright-scip/snapshots/output/unique/grandparent_impl.py +++ b/packages/pyright-scip/snapshots/output/unique/grandparent_impl.py @@ -1,48 +1,25 @@ # < definition scip-python python snapshot-util 0.1 grandparent_impl/__init__: -#documentation (module) grandparent_impl class A: # ^ definition snapshot-util 0.1 grandparent_impl/A# -# documentation ```python -# > class A: -# > ``` def grandparent(self) -> bool: # ^^^^^^^^^^^ definition snapshot-util 0.1 grandparent_impl/A#grandparent(). -# documentation ```python -# > def grandparent( -# > self -# > ) -> bool: -# > ``` # ^^^^ definition snapshot-util 0.1 grandparent_impl/A#grandparent().(self) # ^^^^ reference python-stdlib 3.11 builtins/bool# -# external documentation ```python -# > (class) bool -# > ``` return True class B(A): # ^ definition snapshot-util 0.1 grandparent_impl/B# -# documentation ```python -# > class B(A): -# > ``` # relationship implementation scip-python python snapshot-util 0.1 grandparent_impl/A# # ^ reference snapshot-util 0.1 grandparent_impl/A# ... class C(B): # ^ definition snapshot-util 0.1 grandparent_impl/C# -# documentation ```python -# > class C(B): -# > ``` # relationship implementation scip-python python snapshot-util 0.1 grandparent_impl/B# # ^ reference snapshot-util 0.1 grandparent_impl/B# def grandparent(self) -> bool: # ^^^^^^^^^^^ definition snapshot-util 0.1 grandparent_impl/C#grandparent(). -# documentation ```python -# > def grandparent( -# > self -# > ) -> bool: -# > ``` # relationship implementation scip-python python snapshot-util 0.1 grandparent_impl/A#grandparent(). # ^^^^ definition snapshot-util 0.1 grandparent_impl/C#grandparent().(self) # ^^^^ reference python-stdlib 3.11 builtins/bool# diff --git a/packages/pyright-scip/snapshots/output/unique/inferred_field_docstring.py b/packages/pyright-scip/snapshots/output/unique/inferred_field_docstring.py index 58396834b..c27b07751 100644 --- a/packages/pyright-scip/snapshots/output/unique/inferred_field_docstring.py +++ b/packages/pyright-scip/snapshots/output/unique/inferred_field_docstring.py @@ -1,6 +1,8 @@ # < definition scip-python python snapshot-util 0.1 inferred_field_docstring/__init__: #documentation (module) inferred_field_docstring +# format-options: showDocs + class ClassWithInferredField: # ^^^^^^^^^^^^^^^^^^^^^^ definition snapshot-util 0.1 inferred_field_docstring/ClassWithInferredField# # documentation ```python diff --git a/packages/pyright-scip/snapshots/output/unique/inherits_class.py b/packages/pyright-scip/snapshots/output/unique/inherits_class.py index 7f1965818..54efa385c 100644 --- a/packages/pyright-scip/snapshots/output/unique/inherits_class.py +++ b/packages/pyright-scip/snapshots/output/unique/inherits_class.py @@ -1,37 +1,16 @@ # < definition scip-python python snapshot-util 0.1 inherits_class/__init__: -#documentation (module) inherits_class class A: # ^ definition snapshot-util 0.1 inherits_class/A# -# documentation ```python -# > class A: -# > ``` def x(self) -> int: # ^ definition snapshot-util 0.1 inherits_class/A#x(). -# documentation ```python -# > def x( -# > self -# > ) -> int: -# > ``` # ^^^^ definition snapshot-util 0.1 inherits_class/A#x().(self) # ^^^ reference python-stdlib 3.11 builtins/int# -# external documentation ```python -# > (class) int -# > ``` raise NotImplemented # ^^^^^^^^^^^^^^ reference python-stdlib 3.11 builtins/NotImplemented# -# external documentation ```python -# > (variable) NotImplemented: _NotImplement... -# > ``` def unmatched(self, x: int): # ^^^^^^^^^ definition snapshot-util 0.1 inherits_class/A#unmatched(). -# documentation ```python -# > def unmatched( -# > self, -# > x: int -# > ): # -> None: -# > ``` # ^^^^ definition snapshot-util 0.1 inherits_class/A#unmatched().(self) # ^ definition snapshot-util 0.1 inherits_class/A#unmatched().(x) # ^^^ reference python-stdlib 3.11 builtins/int# @@ -39,18 +18,10 @@ def unmatched(self, x: int): class B(A): # ^ definition snapshot-util 0.1 inherits_class/B# -# documentation ```python -# > class B(A): -# > ``` # relationship implementation scip-python python snapshot-util 0.1 inherits_class/A# # ^ reference snapshot-util 0.1 inherits_class/A# def x(self) -> int: # ^ definition snapshot-util 0.1 inherits_class/B#x(). -# documentation ```python -# > def x( -# > self -# > ) -> int: -# > ``` # relationship implementation scip-python python snapshot-util 0.1 inherits_class/A#x(). # ^^^^ definition snapshot-util 0.1 inherits_class/B#x().(self) # ^^^ reference python-stdlib 3.11 builtins/int# @@ -58,13 +29,6 @@ def x(self) -> int: def unmatched(self, x: int, y: int): # ^^^^^^^^^ definition snapshot-util 0.1 inherits_class/B#unmatched(). -# documentation ```python -# > def unmatched( -# > self, -# > x: int, -# > y: int -# > ): # -> None: -# > ``` # ^^^^ definition snapshot-util 0.1 inherits_class/B#unmatched().(self) # ^ definition snapshot-util 0.1 inherits_class/B#unmatched().(x) # ^^^ reference python-stdlib 3.11 builtins/int# @@ -74,11 +38,6 @@ def unmatched(self, x: int, y: int): def unrelated(self): # ^^^^^^^^^ definition snapshot-util 0.1 inherits_class/B#unrelated(). -# documentation ```python -# > def unrelated( -# > self -# > ): # -> None: -# > ``` # ^^^^ definition snapshot-util 0.1 inherits_class/B#unrelated().(self) pass diff --git a/packages/pyright-scip/snapshots/output/unique/module_docstring.py b/packages/pyright-scip/snapshots/output/unique/module_docstring.py index 24f4dc895..09b60dbac 100644 --- a/packages/pyright-scip/snapshots/output/unique/module_docstring.py +++ b/packages/pyright-scip/snapshots/output/unique/module_docstring.py @@ -2,6 +2,8 @@ #documentation (module) module_docstring #documentation This is a docstring for this module +# format-options: showDocs + """ This is a docstring for this module """ diff --git a/packages/pyright-scip/snapshots/output/unique/multiinherits_test.py b/packages/pyright-scip/snapshots/output/unique/multiinherits_test.py index 467ff399b..8901f3999 100644 --- a/packages/pyright-scip/snapshots/output/unique/multiinherits_test.py +++ b/packages/pyright-scip/snapshots/output/unique/multiinherits_test.py @@ -1,81 +1,40 @@ # < definition scip-python python snapshot-util 0.1 multiinherits_test/__init__: -#documentation (module) multiinherits_test class Left: # ^^^^ definition snapshot-util 0.1 multiinherits_test/Left# -# documentation ```python -# > class Left: -# > ``` def one(self) -> int: # ^^^ definition snapshot-util 0.1 multiinherits_test/Left#one(). -# documentation ```python -# > def one( -# > self -# > ) -> int: -# > ``` # ^^^^ definition snapshot-util 0.1 multiinherits_test/Left#one().(self) # ^^^ reference python-stdlib 3.11 builtins/int# -# external documentation ```python -# > (class) int -# > ``` return 1 def shared(self) -> bool: # ^^^^^^ definition snapshot-util 0.1 multiinherits_test/Left#shared(). -# documentation ```python -# > def shared( -# > self -# > ) -> bool: -# > ``` # ^^^^ definition snapshot-util 0.1 multiinherits_test/Left#shared().(self) # ^^^^ reference python-stdlib 3.11 builtins/bool# -# external documentation ```python -# > (class) bool -# > ``` return False class Right: # ^^^^^ definition snapshot-util 0.1 multiinherits_test/Right# -# documentation ```python -# > class Right: -# > ``` def two(self): # ^^^ definition snapshot-util 0.1 multiinherits_test/Right#two(). -# documentation ```python -# > def two( -# > self -# > ): # -> Literal[2]: -# > ``` # ^^^^ definition snapshot-util 0.1 multiinherits_test/Right#two().(self) return 2 def shared(self) -> bool: # ^^^^^^ definition snapshot-util 0.1 multiinherits_test/Right#shared(). -# documentation ```python -# > def shared( -# > self -# > ) -> bool: -# > ``` # ^^^^ definition snapshot-util 0.1 multiinherits_test/Right#shared().(self) # ^^^^ reference python-stdlib 3.11 builtins/bool# return False class Multi(Left, Right): # ^^^^^ definition snapshot-util 0.1 multiinherits_test/Multi# -# documentation ```python -# > class Multi(Left, Right): -# > ``` # relationship implementation scip-python python snapshot-util 0.1 multiinherits_test/Left# # relationship implementation scip-python python snapshot-util 0.1 multiinherits_test/Right# # ^^^^ reference snapshot-util 0.1 multiinherits_test/Left# # ^^^^^ reference snapshot-util 0.1 multiinherits_test/Right# def one(self) -> int: # ^^^ definition snapshot-util 0.1 multiinherits_test/Multi#one(). -# documentation ```python -# > def one( -# > self -# > ) -> int: -# > ``` # relationship implementation scip-python python snapshot-util 0.1 multiinherits_test/Left#one(). # ^^^^ definition snapshot-util 0.1 multiinherits_test/Multi#one().(self) # ^^^ reference python-stdlib 3.11 builtins/int# @@ -83,32 +42,17 @@ def one(self) -> int: def two(self): # ^^^ definition snapshot-util 0.1 multiinherits_test/Multi#two(). -# documentation ```python -# > def two( -# > self -# > ): # -> Literal[2]: -# > ``` # relationship implementation scip-python python snapshot-util 0.1 multiinherits_test/Right#two(). # ^^^^ definition snapshot-util 0.1 multiinherits_test/Multi#two().(self) return 2 def three(self): # ^^^^^ definition snapshot-util 0.1 multiinherits_test/Multi#three(). -# documentation ```python -# > def three( -# > self -# > ): # -> Literal[3]: -# > ``` # ^^^^ definition snapshot-util 0.1 multiinherits_test/Multi#three().(self) return 3 def shared(self) -> bool: # ^^^^^^ definition snapshot-util 0.1 multiinherits_test/Multi#shared(). -# documentation ```python -# > def shared( -# > self -# > ) -> bool: -# > ``` # relationship implementation scip-python python snapshot-util 0.1 multiinherits_test/Left#shared(). # relationship implementation scip-python python snapshot-util 0.1 multiinherits_test/Right#shared(). # ^^^^ definition snapshot-util 0.1 multiinherits_test/Multi#shared().(self) diff --git a/packages/pyright-scip/snapshots/output/unique/property_access.py b/packages/pyright-scip/snapshots/output/unique/property_access.py index 189984d48..2d20e93bc 100644 --- a/packages/pyright-scip/snapshots/output/unique/property_access.py +++ b/packages/pyright-scip/snapshots/output/unique/property_access.py @@ -1,107 +1,40 @@ # < definition scip-python python snapshot-util 0.1 property_access/__init__: -#documentation (module) property_access from typing import Sequence # ^^^^^^ reference python-stdlib 3.11 typing/__init__: -# external documentation ```python -# > (module) typing -# > ``` -# external documentation --- -# > -# external documentation The typing module: Support for gradual t... -# > -# > At large scale, the structure of the mod... -# > * Imports and exports, all public names... -# > * Internal helper functions: these shou... -# > * \_SpecialForm and its instances (spec... -# > Any, NoReturn, ClassVar, Union, Optional... -# > * Classes whose instances can be type a... -# > ForwardRef, TypeVar and ParamSpec -# > * The core of internal generics API: \_... -# > currently only used by Tuple and Callabl... -# > etc., are instances of either of these c... -# > * The public counterpart of the generic... -# > * Public helper functions: get\_type\_h... -# > no\_type\_check\_decorator. -# > * Generic aliases for collections.abc A... -# > * Special types: NewType, NamedTuple, T... -# > * Wrapper submodules for re and io rela... # ^^^^^^^^ reference python-stdlib 3.11 typing/Sequence# class PropertyClass: # ^^^^^^^^^^^^^ definition snapshot-util 0.1 property_access/PropertyClass# -# documentation ```python -# > class PropertyClass: -# > ``` def __init__(self): # ^^^^^^^^ definition snapshot-util 0.1 property_access/PropertyClass#__init__(). -# documentation ```python -# > def __init__( -# > self -# > ) -> None: -# > ``` # ^^^^ definition snapshot-util 0.1 property_access/PropertyClass#__init__().(self) pass @property # ^^^^^^^^ reference python-stdlib 3.11 builtins/property# -# external documentation ```python -# > (class) property -# > ``` def prop_ref(self): # ^^^^^^^^ definition snapshot-util 0.1 property_access/PropertyClass#prop_ref(). -# documentation ```python -# > @property -# > def prop_ref( -# > self -# > ): # -> Literal[5]: -# > ``` # ^^^^ definition snapshot-util 0.1 property_access/PropertyClass#prop_ref().(self) return 5 xs = [PropertyClass()] #^ definition snapshot-util 0.1 property_access/xs. -#documentation ```python -# > builtins.list -# > ``` # ^^^^^^^^^^^^^ reference snapshot-util 0.1 property_access/PropertyClass# def usage(xs: Sequence[PropertyClass]): # ^^^^^ definition snapshot-util 0.1 property_access/usage(). -# documentation ```python -# > def usage( -# > xs: Sequence[PropertyClass] -# > ): # -> None: -# > ``` # ^^ definition snapshot-util 0.1 property_access/usage().(xs) # ^^^^^^^^ reference python-stdlib 3.11 typing/Sequence# # ^^^^^^^^^^^^^ reference snapshot-util 0.1 property_access/PropertyClass# def nested(): # ^^^^^^ definition snapshot-util 0.1 property_access/usage().nested(). -# documentation ```python -# > def nested(): # -> None: -# > ``` 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(). -# 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 property_access/PropertyClass#prop_ref(). 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 4a2109f4f..5b8d297b9 100644 --- a/packages/pyright-scip/snapshots/output/unique/vars_inside_scopes.py +++ b/packages/pyright-scip/snapshots/output/unique/vars_inside_scopes.py @@ -1,75 +1,25 @@ # < definition scip-python python snapshot-util 0.1 vars_inside_scopes/__init__: -#documentation (module) vars_inside_scopes from typing import List # ^^^^^^ reference python-stdlib 3.11 typing/__init__: -# external documentation ```python -# > (module) typing -# > ``` -# external documentation --- -# > -# external documentation The typing module: Support for gradual t... -# > -# > At large scale, the structure of the mod... -# > * Imports and exports, all public names... -# > * Internal helper functions: these shou... -# > * \_SpecialForm and its instances (spec... -# > Any, NoReturn, ClassVar, Union, Optional... -# > * Classes whose instances can be type a... -# > ForwardRef, TypeVar and ParamSpec -# > * The core of internal generics API: \_... -# > currently only used by Tuple and Callabl... -# > etc., are instances of either of these c... -# > * The public counterpart of the generic... -# > * Public helper functions: get\_type\_h... -# > no\_type\_check\_decorator. -# > * Generic aliases for collections.abc A... -# > * Special types: NewType, NamedTuple, T... -# > * Wrapper submodules for re and io rela... # ^^^^ reference python-stdlib 3.11 typing/List. -# external documentation ```python -# > (variable) List: Type[List[_T@list]] -# > ``` class X: # ^ definition snapshot-util 0.1 vars_inside_scopes/X# -# documentation ```python -# > class X: -# > ``` items: List[int] # ^^^^^ definition snapshot-util 0.1 vars_inside_scopes/X#items. -# documentation ```python -# > (variable) items: List[int] -# > ``` # ^^^^ reference python-stdlib 3.11 typing/List. # ^^^ reference python-stdlib 3.11 builtins/int# -# external documentation ```python -# > (class) int -# > ``` def my_func(self): # ^^^^^^^ definition snapshot-util 0.1 vars_inside_scopes/X#my_func(). -# documentation ```python -# > def my_func( -# > self -# > ): # -> None: -# > ``` # ^^^^ 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 # ^ definition local 1 -# documentation ```python -# > builtins.int -# > ``` # ^ reference local 0 if 5 in self.items: @@ -77,7 +27,4 @@ def my_func(self): # ^^^^^ reference snapshot-util 0.1 vars_inside_scopes/X#items. z = "oh ya" # ^ definition local 2 -# documentation ```python -# > builtins.str -# > ``` diff --git a/packages/pyright-scip/snapshots/output/unique/walrus.py b/packages/pyright-scip/snapshots/output/unique/walrus.py index ea2a6d69b..535038ba4 100644 --- a/packages/pyright-scip/snapshots/output/unique/walrus.py +++ b/packages/pyright-scip/snapshots/output/unique/walrus.py @@ -1,47 +1,22 @@ # < 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: @@ -59,17 +34,11 @@ # 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 @@ -80,12 +49,6 @@ def show_some_comprehension(): 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. @@ -94,18 +57,9 @@ def show_some_comprehension(): # 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(). diff --git a/packages/pyright-scip/snapshots/output/unresolved_import/unresolved.py b/packages/pyright-scip/snapshots/output/unresolved_import/unresolved.py index 602259f89..94afbc56d 100644 --- a/packages/pyright-scip/snapshots/output/unresolved_import/unresolved.py +++ b/packages/pyright-scip/snapshots/output/unresolved_import/unresolved.py @@ -1,21 +1,10 @@ # < definition scip-python python snapshot-util 0.1 unresolved/__init__: -#documentation (module) unresolved import this_is_not_real # ^^^^^^^^^^^^^^^^ reference local 0 -# documentation (module): this_is_not_real [unable to re... print(this_is_not_real.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 local 0 print(this_is_not_real.x) #^^^^ reference python-stdlib 3.11 builtins/print(). diff --git a/packages/pyright-scip/src/lib.ts b/packages/pyright-scip/src/lib.ts index a30e4300e..388f1033b 100644 --- a/packages/pyright-scip/src/lib.ts +++ b/packages/pyright-scip/src/lib.ts @@ -31,6 +31,39 @@ function getSymbolTable(doc: scip.Document): Map const packageName = 'scip-python python'; const commentSyntax = '#'; +const formatOptionsPrefix = '# format-options:'; + +function parseOptions(lines: string[]): { + showDocs: boolean; + showRanges: boolean; +} { + const formatOptions = { + showDocs: false, + showRanges: false, + }; + + for (let line of lines) { + if (!line.startsWith(formatOptionsPrefix)) { + continue; + } + + const options = line.slice(formatOptionsPrefix.length).trim().split(','); + + for (let option of options) { + const optionName = option.trim(); + + if (!(optionName in formatOptions)) { + throw new Error(`Invalid format option: ${optionName}`); + } + + formatOptions[optionName as keyof typeof formatOptions] = true; + } + + break; + } + + return formatOptions; +} export function formatSnapshot( input: Input, @@ -45,12 +78,33 @@ export function formatSnapshot( externalSymbolTable.set(externalSymbol.symbol, externalSymbol); } + const enclosingRanges: { range: Range; symbol: string }[] = []; const symbolsWithDefinitions: Set = new Set(); + + const formatOptions = parseOptions(input.lines); + for (let occurrence of doc.occurrences) { const isDefinition = (occurrence.symbol_roles & scip.SymbolRole.Definition) > 0; if (isDefinition) { symbolsWithDefinitions.add(occurrence.symbol); } + + if (formatOptions.showRanges && occurrence.enclosing_range.length > 0) { + enclosingRanges.push({ + range: Range.fromLsif(occurrence.enclosing_range), + symbol: occurrence.symbol, + }); + } + } + + enclosingRanges.sort(enclosingRangesByLine); + + const enclosingRangeStarts: (typeof enclosingRanges)[number][][] = Array.from(Array(input.lines.length), () => []); + const enclosingRangeEnds: (typeof enclosingRanges)[number][][] = Array.from(Array(input.lines.length), () => []); + + for (const enclosingRange of enclosingRanges) { + enclosingRangeStarts[enclosingRange.range.start.line].push(enclosingRange); + enclosingRangeEnds[enclosingRange.range.end.line].unshift(enclosingRange); } const emittedDocstrings: Set = new Set(); @@ -75,6 +129,10 @@ export function formatSnapshot( } const pushOneDoc = (docs: string[], external: boolean) => { + if (!formatOptions.showDocs) { + return; + } + for (const documentation of docs) { for (const [idx, line] of documentation.split('\n').entries()) { out.push(prefix); @@ -127,8 +185,41 @@ export function formatSnapshot( out.push('\n'); }; + const pushEnclosingRange = ( + enclosingRange: { + range: Range; + symbol: string; + }, + end: boolean = false + ) => { + if (!formatOptions.showRanges) { + return; + } + + out.push(commentSyntax); + out.push(' '.repeat(Math.max(1, enclosingRange.range.start.character - 1))); + + if (enclosingRange.range.start.character < 2) { + out.push('<'); + } else if (end) { + out.push('^'); + } else { + out.push('⌄'); + } + + if (end) { + out.push(' end '); + } else { + out.push(' start '); + } + out.push('enclosing_range '); + out.push(enclosingRange.symbol); + out.push('\n'); + }; + doc.occurrences.sort(occurrencesByLine); let occurrenceIndex = 0; + for (const [lineNumber, line] of input.lines.entries()) { // Write 0,0 items ABOVE the first line. // This is the only case where we would need to do this. @@ -152,6 +243,11 @@ export function formatSnapshot( } } + // Check if any enclosing ranges start on this line + for (const enclosingRange of enclosingRangeStarts[lineNumber]) { + pushEnclosingRange(enclosingRange); + } + out.push(''); out.push(line); out.push('\n'); @@ -196,6 +292,11 @@ export function formatSnapshot( pushDoc(range, occurrence.symbol, isDefinition, isStartOfLine); } + + // Check if any enclosing ranges end on this line + for (const enclosingRange of enclosingRangeEnds[lineNumber]) { + pushEnclosingRange(enclosingRange, true); + } } return out.join(''); } @@ -231,3 +332,14 @@ export function diffSnapshot(outputPath: string, obtained: string): void { function occurrencesByLine(a: scip.Occurrence, b: scip.Occurrence): number { return Range.fromLsif(a.range).compare(Range.fromLsif(b.range)); } + +function enclosingRangesByLine(a: { range: Range; symbol: string }, b: { range: Range; symbol: string }): number { + // Return the range that starts first, and if they start at the same line, the one that ends last (enclosing). + const rangeCompare = a.range.compare(b.range); + + if (rangeCompare !== 0) { + return rangeCompare; + } + + return b.range.end.line - a.range.end.line; +} diff --git a/packages/pyright-scip/src/scip.ts b/packages/pyright-scip/src/scip.ts index 537aa2e7c..d685461c9 100644 --- a/packages/pyright-scip/src/scip.ts +++ b/packages/pyright-scip/src/scip.ts @@ -22,13 +22,16 @@ export namespace scip { WriteAccess = 4, ReadAccess = 8, Generated = 16, - Test = 32 + Test = 32, + ForwardDefinition = 64 } export enum SyntaxKind { UnspecifiedSyntaxKind = 0, Comment = 1, PunctuationDelimiter = 2, PunctuationBracket = 3, + Keyword = 4, + /** @deprecated*/ IdentifierKeyword = 4, IdentifierOperator = 5, Identifier = 6, @@ -80,6 +83,7 @@ export namespace scip { export enum Language { UnspecifiedLanguage = 0, ABAP = 60, + Apex = 96, APL = 49, Ada = 39, Agda = 45, @@ -97,6 +101,7 @@ export namespace scip { Coffeescript = 21, CommonLisp = 9, Coq = 47, + CUDA = 97, Dart = 3, Delphi = 57, Diff = 88, @@ -112,6 +117,7 @@ export namespace scip { Git_Config = 89, Git_Rebase = 92, Go = 33, + GraphQL = 98, Groovy = 7, HTML = 30, Hack = 20, @@ -126,28 +132,34 @@ export namespace scip { JavaScriptReact = 93, Jsonnet = 76, Julia = 55, + Justfile = 109, Kotlin = 4, LaTeX = 83, Lean = 48, Less = 27, Lua = 12, + Luau = 108, Makefile = 79, Markdown = 84, Matlab = 52, + Nickel = 110, Nix = 77, OCaml = 41, Objective_C = 36, Objective_CPP = 37, + Pascal = 99, PHP = 19, PLSQL = 70, Perl = 13, PowerShell = 67, Prolog = 71, + Protobuf = 100, Python = 15, R = 54, Racket = 11, Raku = 14, Razor = 62, + Repro = 102, ReST = 85, Ruby = 16, Rust = 40, @@ -160,11 +172,18 @@ export namespace scip { Scheme = 10, ShellScript = 64, Skylark = 78, + Slang = 107, + Solidity = 95, + Svelte = 106, Swift = 2, + Tcl = 101, TOML = 73, TeX = 82, + Thrift = 103, TypeScript = 23, TypeScriptReact = 94, + Verilog = 104, + VHDL = 105, VisualBasic = 63, Vue = 25, Wolfram = 53, @@ -548,6 +567,7 @@ export namespace scip { relative_path?: string; occurrences?: Occurrence[]; symbols?: SymbolInformation[]; + text?: string; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3], this.#one_of_decls); @@ -564,6 +584,9 @@ export namespace scip { if ("symbols" in data && data.symbols != undefined) { this.symbols = data.symbols; } + if ("text" in data && data.text != undefined) { + this.text = data.text; + } } } get language() { @@ -590,11 +613,18 @@ export namespace scip { set symbols(value: SymbolInformation[]) { pb_1.Message.setRepeatedWrapperField(this, 3, value); } + get text() { + return pb_1.Message.getFieldWithDefault(this, 5, "") as string; + } + set text(value: string) { + pb_1.Message.setField(this, 5, value); + } static fromObject(data: { language?: string; relative_path?: string; occurrences?: ReturnType[]; symbols?: ReturnType[]; + text?: string; }): Document { const message = new Document({}); if (data.language != null) { @@ -609,6 +639,9 @@ export namespace scip { if (data.symbols != null) { message.symbols = data.symbols.map(item => SymbolInformation.fromObject(item)); } + if (data.text != null) { + message.text = data.text; + } return message; } toObject() { @@ -617,6 +650,7 @@ export namespace scip { relative_path?: string; occurrences?: ReturnType[]; symbols?: ReturnType[]; + text?: string; } = {}; if (this.language != null) { data.language = this.language; @@ -630,6 +664,9 @@ export namespace scip { if (this.symbols != null) { data.symbols = this.symbols.map((item: SymbolInformation) => item.toObject()); } + if (this.text != null) { + data.text = this.text; + } return data; } serialize(): Uint8Array; @@ -644,6 +681,8 @@ export namespace scip { writer.writeRepeatedMessage(2, this.occurrences, (item: Occurrence) => item.serialize(writer)); if (this.symbols.length) writer.writeRepeatedMessage(3, this.symbols, (item: SymbolInformation) => item.serialize(writer)); + if (this.text.length) + writer.writeString(5, this.text); if (!w) return writer.getResultBuffer(); } @@ -665,6 +704,9 @@ export namespace scip { case 3: reader.readMessage(message.symbols, () => pb_1.Message.addToRepeatedWrapperField(message, 3, SymbolInformation.deserialize(reader), SymbolInformation)); break; + case 5: + message.text = reader.readString(); + break; default: reader.skipField(); } } @@ -1031,7 +1073,8 @@ export namespace scip { TypeParameter = 5, Parameter = 6, Meta = 7, - Local = 8 + Local = 8, + Macro = 9 } } export class SymbolInformation extends pb_1.Message { @@ -1040,6 +1083,10 @@ export namespace scip { symbol?: string; documentation?: string[]; relationships?: Relationship[]; + kind?: SymbolInformation.Kind; + display_name?: string; + signature_documentation?: Document; + enclosing_symbol?: string; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 4], this.#one_of_decls); @@ -1053,6 +1100,18 @@ export namespace scip { if ("relationships" in data && data.relationships != undefined) { this.relationships = data.relationships; } + if ("kind" in data && data.kind != undefined) { + this.kind = data.kind; + } + if ("display_name" in data && data.display_name != undefined) { + this.display_name = data.display_name; + } + if ("signature_documentation" in data && data.signature_documentation != undefined) { + this.signature_documentation = data.signature_documentation; + } + if ("enclosing_symbol" in data && data.enclosing_symbol != undefined) { + this.enclosing_symbol = data.enclosing_symbol; + } } } get symbol() { @@ -1073,10 +1132,41 @@ export namespace scip { set relationships(value: Relationship[]) { pb_1.Message.setRepeatedWrapperField(this, 4, value); } + get kind() { + return pb_1.Message.getFieldWithDefault(this, 5, SymbolInformation.Kind.UnspecifiedKind) as SymbolInformation.Kind; + } + set kind(value: SymbolInformation.Kind) { + pb_1.Message.setField(this, 5, value); + } + get display_name() { + return pb_1.Message.getFieldWithDefault(this, 6, "") as string; + } + set display_name(value: string) { + pb_1.Message.setField(this, 6, value); + } + get signature_documentation() { + return pb_1.Message.getWrapperField(this, Document, 7) as Document; + } + set signature_documentation(value: Document) { + pb_1.Message.setWrapperField(this, 7, value); + } + get has_signature_documentation() { + return pb_1.Message.getField(this, 7) != null; + } + get enclosing_symbol() { + return pb_1.Message.getFieldWithDefault(this, 8, "") as string; + } + set enclosing_symbol(value: string) { + pb_1.Message.setField(this, 8, value); + } static fromObject(data: { symbol?: string; documentation?: string[]; relationships?: ReturnType[]; + kind?: SymbolInformation.Kind; + display_name?: string; + signature_documentation?: ReturnType; + enclosing_symbol?: string; }): SymbolInformation { const message = new SymbolInformation({}); if (data.symbol != null) { @@ -1088,6 +1178,18 @@ export namespace scip { if (data.relationships != null) { message.relationships = data.relationships.map(item => Relationship.fromObject(item)); } + if (data.kind != null) { + message.kind = data.kind; + } + if (data.display_name != null) { + message.display_name = data.display_name; + } + if (data.signature_documentation != null) { + message.signature_documentation = Document.fromObject(data.signature_documentation); + } + if (data.enclosing_symbol != null) { + message.enclosing_symbol = data.enclosing_symbol; + } return message; } toObject() { @@ -1095,6 +1197,10 @@ export namespace scip { symbol?: string; documentation?: string[]; relationships?: ReturnType[]; + kind?: SymbolInformation.Kind; + display_name?: string; + signature_documentation?: ReturnType; + enclosing_symbol?: string; } = {}; if (this.symbol != null) { data.symbol = this.symbol; @@ -1105,6 +1211,18 @@ export namespace scip { if (this.relationships != null) { data.relationships = this.relationships.map((item: Relationship) => item.toObject()); } + if (this.kind != null) { + data.kind = this.kind; + } + if (this.display_name != null) { + data.display_name = this.display_name; + } + if (this.signature_documentation != null) { + data.signature_documentation = this.signature_documentation.toObject(); + } + if (this.enclosing_symbol != null) { + data.enclosing_symbol = this.enclosing_symbol; + } return data; } serialize(): Uint8Array; @@ -1117,6 +1235,14 @@ export namespace scip { writer.writeRepeatedString(3, this.documentation); if (this.relationships.length) writer.writeRepeatedMessage(4, this.relationships, (item: Relationship) => item.serialize(writer)); + if (this.kind != SymbolInformation.Kind.UnspecifiedKind) + writer.writeEnum(5, this.kind); + if (this.display_name.length) + writer.writeString(6, this.display_name); + if (this.has_signature_documentation) + writer.writeMessage(7, this.signature_documentation, () => this.signature_documentation.serialize(writer)); + if (this.enclosing_symbol.length) + writer.writeString(8, this.enclosing_symbol); if (!w) return writer.getResultBuffer(); } @@ -1135,6 +1261,18 @@ export namespace scip { case 4: reader.readMessage(message.relationships, () => pb_1.Message.addToRepeatedWrapperField(message, 4, Relationship.deserialize(reader), Relationship)); break; + case 5: + message.kind = reader.readEnum(); + break; + case 6: + message.display_name = reader.readString(); + break; + case 7: + reader.readMessage(message.signature_documentation, () => message.signature_documentation = Document.deserialize(reader)); + break; + case 8: + message.enclosing_symbol = reader.readString(); + break; default: reader.skipField(); } } @@ -1147,6 +1285,93 @@ export namespace scip { return SymbolInformation.deserialize(bytes); } } + export namespace SymbolInformation { + export enum Kind { + UnspecifiedKind = 0, + AbstractMethod = 66, + Accessor = 72, + Array = 1, + Assertion = 2, + AssociatedType = 3, + Attribute = 4, + Axiom = 5, + Boolean = 6, + Class = 7, + Constant = 8, + Constructor = 9, + Contract = 62, + DataFamily = 10, + Delegate = 73, + Enum = 11, + EnumMember = 12, + Error = 63, + Event = 13, + Fact = 14, + Field = 15, + File = 16, + Function = 17, + Getter = 18, + Grammar = 19, + Instance = 20, + Interface = 21, + Key = 22, + Lang = 23, + Lemma = 24, + Library = 64, + Macro = 25, + Method = 26, + MethodAlias = 74, + MethodReceiver = 27, + MethodSpecification = 67, + Message = 28, + Modifier = 65, + Module = 29, + Namespace = 30, + Null = 31, + Number = 32, + Object = 33, + Operator = 34, + Package = 35, + PackageObject = 36, + Parameter = 37, + ParameterLabel = 38, + Pattern = 39, + Predicate = 40, + Property = 41, + Protocol = 42, + ProtocolMethod = 68, + PureVirtualMethod = 69, + Quasiquoter = 43, + SelfParameter = 44, + Setter = 45, + Signature = 46, + SingletonClass = 75, + SingletonMethod = 76, + StaticDataMember = 77, + StaticEvent = 78, + StaticField = 79, + StaticMethod = 80, + StaticProperty = 81, + StaticVariable = 82, + String = 48, + Struct = 49, + Subscript = 47, + Tactic = 50, + Theorem = 51, + ThisParameter = 52, + Trait = 53, + TraitMethod = 70, + Type = 54, + TypeAlias = 55, + TypeClass = 56, + TypeClassMethod = 71, + TypeFamily = 57, + TypeParameter = 58, + Union = 59, + Value = 60, + Variable = 61 + } + } export class Relationship extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -1154,6 +1379,7 @@ export namespace scip { is_reference?: boolean; is_implementation?: boolean; is_type_definition?: boolean; + is_definition?: boolean; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -1170,6 +1396,9 @@ export namespace scip { if ("is_type_definition" in data && data.is_type_definition != undefined) { this.is_type_definition = data.is_type_definition; } + if ("is_definition" in data && data.is_definition != undefined) { + this.is_definition = data.is_definition; + } } } get symbol() { @@ -1196,11 +1425,18 @@ export namespace scip { set is_type_definition(value: boolean) { pb_1.Message.setField(this, 4, value); } + get is_definition() { + return pb_1.Message.getFieldWithDefault(this, 5, false) as boolean; + } + set is_definition(value: boolean) { + pb_1.Message.setField(this, 5, value); + } static fromObject(data: { symbol?: string; is_reference?: boolean; is_implementation?: boolean; is_type_definition?: boolean; + is_definition?: boolean; }): Relationship { const message = new Relationship({}); if (data.symbol != null) { @@ -1215,6 +1451,9 @@ export namespace scip { if (data.is_type_definition != null) { message.is_type_definition = data.is_type_definition; } + if (data.is_definition != null) { + message.is_definition = data.is_definition; + } return message; } toObject() { @@ -1223,6 +1462,7 @@ export namespace scip { is_reference?: boolean; is_implementation?: boolean; is_type_definition?: boolean; + is_definition?: boolean; } = {}; if (this.symbol != null) { data.symbol = this.symbol; @@ -1236,6 +1476,9 @@ export namespace scip { if (this.is_type_definition != null) { data.is_type_definition = this.is_type_definition; } + if (this.is_definition != null) { + data.is_definition = this.is_definition; + } return data; } serialize(): Uint8Array; @@ -1250,6 +1493,8 @@ export namespace scip { writer.writeBool(3, this.is_implementation); if (this.is_type_definition != false) writer.writeBool(4, this.is_type_definition); + if (this.is_definition != false) + writer.writeBool(5, this.is_definition); if (!w) return writer.getResultBuffer(); } @@ -1271,6 +1516,9 @@ export namespace scip { case 4: message.is_type_definition = reader.readBool(); break; + case 5: + message.is_definition = reader.readBool(); + break; default: reader.skipField(); } } @@ -1292,9 +1540,10 @@ export namespace scip { override_documentation?: string[]; syntax_kind?: SyntaxKind; diagnostics?: Diagnostic[]; + enclosing_range?: number[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 4, 6], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 4, 6, 7], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("range" in data && data.range != undefined) { this.range = data.range; @@ -1314,6 +1563,9 @@ export namespace scip { if ("diagnostics" in data && data.diagnostics != undefined) { this.diagnostics = data.diagnostics; } + if ("enclosing_range" in data && data.enclosing_range != undefined) { + this.enclosing_range = data.enclosing_range; + } } } get range() { @@ -1352,6 +1604,12 @@ export namespace scip { set diagnostics(value: Diagnostic[]) { pb_1.Message.setRepeatedWrapperField(this, 6, value); } + get enclosing_range() { + return pb_1.Message.getFieldWithDefault(this, 7, []) as number[]; + } + set enclosing_range(value: number[]) { + pb_1.Message.setField(this, 7, value); + } static fromObject(data: { range?: number[]; symbol?: string; @@ -1359,6 +1617,7 @@ export namespace scip { override_documentation?: string[]; syntax_kind?: SyntaxKind; diagnostics?: ReturnType[]; + enclosing_range?: number[]; }): Occurrence { const message = new Occurrence({}); if (data.range != null) { @@ -1379,6 +1638,9 @@ export namespace scip { if (data.diagnostics != null) { message.diagnostics = data.diagnostics.map(item => Diagnostic.fromObject(item)); } + if (data.enclosing_range != null) { + message.enclosing_range = data.enclosing_range; + } return message; } toObject() { @@ -1389,6 +1651,7 @@ export namespace scip { override_documentation?: string[]; syntax_kind?: SyntaxKind; diagnostics?: ReturnType[]; + enclosing_range?: number[]; } = {}; if (this.range != null) { data.range = this.range; @@ -1408,6 +1671,9 @@ export namespace scip { if (this.diagnostics != null) { data.diagnostics = this.diagnostics.map((item: Diagnostic) => item.toObject()); } + if (this.enclosing_range != null) { + data.enclosing_range = this.enclosing_range; + } return data; } serialize(): Uint8Array; @@ -1426,6 +1692,8 @@ export namespace scip { writer.writeEnum(5, this.syntax_kind); if (this.diagnostics.length) writer.writeRepeatedMessage(6, this.diagnostics, (item: Diagnostic) => item.serialize(writer)); + if (this.enclosing_range.length) + writer.writePackedInt32(7, this.enclosing_range); if (!w) return writer.getResultBuffer(); } @@ -1453,6 +1721,9 @@ export namespace scip { case 6: reader.readMessage(message.diagnostics, () => pb_1.Message.addToRepeatedWrapperField(message, 6, Diagnostic.deserialize(reader), Diagnostic)); break; + case 7: + message.enclosing_range = reader.readPackedInt32(); + break; default: reader.skipField(); } } @@ -1519,7 +1790,7 @@ export namespace scip { pb_1.Message.setField(this, 4, value); } get tags() { - return pb_1.Message.getFieldWithDefault(this, 5, DiagnosticTag.UnspecifiedDiagnosticTag) as DiagnosticTag[]; + return pb_1.Message.getFieldWithDefault(this, 5, []) as DiagnosticTag[]; } set tags(value: DiagnosticTag[]) { pb_1.Message.setField(this, 5, value); diff --git a/packages/pyright-scip/src/treeVisitor.ts b/packages/pyright-scip/src/treeVisitor.ts index 5bfcd9ea6..69115d90e 100644 --- a/packages/pyright-scip/src/treeVisitor.ts +++ b/packages/pyright-scip/src/treeVisitor.ts @@ -574,7 +574,14 @@ export class TreeVisitor extends ParseTreeWalker { const existingSymbol = this.rawGetLsifSymbol(decl.node); if (existingSymbol) { if (decl.node.id === parent.id || decl.node.id === node.id) { - this.pushNewOccurrence(node, existingSymbol, scip.SymbolRole.Definition); + switch (decl.node.nodeType) { + case ParseNodeType.Function: + case ParseNodeType.Class: + this.pushNewOccurrence(node, existingSymbol, scip.SymbolRole.Definition, decl.node); + break; + default: + this.pushNewOccurrence(node, existingSymbol, scip.SymbolRole.Definition); + } } else { this.pushNewOccurrence(node, existingSymbol); } @@ -712,7 +719,8 @@ export class TreeVisitor extends ParseTreeWalker { } if (isDefinition) { - switch (parent.nodeType) { + // In this case, decl.node == node.parent + switch (decl.node.nodeType) { case ParseNodeType.Class: { const symbol = this.getScipSymbol(parent); @@ -722,7 +730,7 @@ export class TreeVisitor extends ParseTreeWalker { documentation.push('```python\n' + stub.join('\n') + '\n```'); } - const doc = ParseTreeUtils.getDocString(parent.suite.statements)?.trim(); + const doc = ParseTreeUtils.getDocString(decl.node.suite.statements)?.trim(); if (doc) { documentation.push(convertDocStringToMarkdown(doc)); } @@ -779,10 +787,15 @@ export class TreeVisitor extends ParseTreeWalker { relationships, }) ); + + this.pushNewOccurrence(node, this.getScipSymbol(decl.node), scip.SymbolRole.Definition, decl.node); + break; + } + default: { + this.pushNewOccurrence(node, this.getScipSymbol(decl.node), scip.SymbolRole.Definition); } } - this.pushNewOccurrence(node, this.getScipSymbol(decl.node), scip.SymbolRole.Definition); return true; } @@ -1377,7 +1390,13 @@ export class TreeVisitor extends ParseTreeWalker { } // Might be the only way we can add new occurrences? - private pushNewOccurrence(node: ParseNode, symbol: ScipSymbol, role: number = scip.SymbolRole.ReadAccess): void { + private pushNewOccurrence( + node: ParseNode, + symbol: ScipSymbol, + role: number = scip.SymbolRole.ReadAccess, + // TODO(issue: https://github.com/sourcegraph/scip-python/issues/134) + decl?: FunctionNode | ClassNode + ): void { softAssert(symbol.value.trim() == symbol.value, `Invalid symbol ${node} -> ${symbol.value}`); this.document.occurrences.push( @@ -1385,6 +1404,7 @@ export class TreeVisitor extends ParseTreeWalker { symbol_roles: role, symbol: symbol.value, range: parseNodeToRange(node, this.fileInfo!.lines).toLsif(), + enclosing_range: decl && parseNodeToRange(decl, this.fileInfo!.lines).toLsif(), }) ); }