fix: Avoid crash in the presence of decorators.#184
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
e330ce9 to
34a3753
Compare
| # ^^^ reference python-stdlib 3.11 builtins/int# | ||
| def matched_despite_different_type(self, x: int, y: int): | ||
| # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition snapshot-util 0.1 inherits_class/B#matched_despite_different_type(). | ||
| # relationship implementation scip-python python snapshot-util 0.1 inherits_class/A#matched_despite_different_type(). |
There was a problem hiding this comment.
This relationship is new. Python's overriding is based purely on name, not on types, so this is more accurate if we're looking at the runtime behavior.
| def shared(self) -> bool: | ||
| # ^^^^^^ definition snapshot-util 0.1 multiinherits_test/Multi#shared(). | ||
| # 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(). |
There was a problem hiding this comment.
This relationship is done, because based on MRO, only one of the parent class methods will be considered for overriding.
| ); | ||
| } | ||
|
|
||
| let decl = parentMethodType.details.declaration!; |
There was a problem hiding this comment.
This ! triggered the error reported in GRAPH-1278.
| } | ||
| } | ||
|
|
||
| // NOTE(tech-debt): typeToSymbol's signature doesn't make sense. It returns the |
There was a problem hiding this comment.
Symbols should be purely based on declarations.
For example: https://sourcegraph.sourcegraph.com/github.com/sourcegraph/scip-clang/-/blob/indexer/SymbolFormatter.cc?L707
| @@ -0,0 +1,21 @@ | |||
| from typing import TypeVar, Generic, Callable, Iterator, ParamSpec | |||
There was a problem hiding this comment.
This test cases seems a bit large, but I haven't been able to minimize it further.
34a3753 to
5d4d868
Compare
Changes the method lookup logic to use the same logic as Pyright internals instead of our own ad-hoc implementation of name resolution, which does not match Python's method resolution order (MRO), which is based purely on names, and not on types. This gets rid of a code path where we were doing a `!` operation, which triggered a crash when indexing a prospect's codebase. Fixes GRAPH-1278.

Changes the method lookup logic to use the same
logic as Pyright internals instead of our own ad-hoc
implementation of name resolution, which does not
match Python's method resolution order (MRO), which
is based purely on names, and not on types.
This gets rid of a code path where we were doing a
!operation, which triggered a crash when indexing
a prospect's codebase.
Fixes GRAPH-1278.