-
Notifications
You must be signed in to change notification settings - Fork 85
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-1796 Infer types for set, dict and tuple literals #1773
SONARPY-1796 Infer types for set, dict and tuple literals #1773
Conversation
3e6ca06
to
7fcfc51
Compare
a22dca6
to
5ee5e31
Compare
a2d55d2
to
6ac36b5
Compare
6ac36b5
to
4cf3e3b
Compare
} | ||
ModuleType builtins = this.projectLevelTypeTable.getModule(BUILTINS); | ||
PythonType tupleType = builtins.resolveMember("tuple").orElse(PythonType.UNKNOWN); | ||
((TupleImpl) tuple).typeV2(new ObjectType(tupleType, attributes, List.of())); |
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.
using List.of()
could be dangerous since it is immutable. I'd prefer to use array lists instead
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.
LGTM
Quality Gate passedIssues Measures |
bfea989
into
rnd/type-inference-engine-specification
Tuple content type is inferred immediately if (and unique) available as tuple are immutables.
This should be seen as a baby step/low-hanging fruit. I'd expect a dedicated effort to tackle any more complex case.
Also, this PR does not deal with display name/representation of those generic types.
Not 100% related to the ticket, but I also took the opportunity to add some missing test for some already covered literal types (str, numeric literals and None).