New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SONARPY-1801 infer type of subscription expression when it is a class with generic type #1776
base: rnd/type-inference-engine-specification
Are you sure you want to change the base?
SONARPY-1801 infer type of subscription expression when it is a class with generic type #1776
Conversation
0ad5542
to
b230d05
Compare
b230d05
to
6bc838b
Compare
… with generic type
6bc838b
to
bd2b352
Compare
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about keeping this logic in the Tree
itself despite the fact we did that in the previous implementation. I think it would make sense to do it during the visit of TypeInferenceV2
to centralize the places where types are set (I realize it's actually quite difficult to know where a type is set in the current implementation, as it can happen in many places...).
I'm also unsure about the edge cases we could face with this. Ideally it could be nice to have an extra test for a possible edge case that is actually not generic (if it exists0>
@@ -77,4 +79,13 @@ public List<Tree> computeChildren() { | |||
public Kind getKind() { | |||
return Kind.SUBSCRIPTION; | |||
} | |||
|
|||
@Override | |||
public PythonType typeV2() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instinctively, I believe typeV2()
should ideally only be a getter for types.
I believe the logic of this method would make more sense in TypeInferenceV2
itself.
I see in the previous implementation this was done in CallExpressionImpl
directly, using a similar logic, though. It did have some checks to ensure we were indeed dealing with a generic type, I think it would make sense to have it as well to avoid edge cases (I guess you could create a class where the class object itself has a __getitem__
method...
No description provided.