Skip to content
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-2194 Prevent the creation of ObjectType[UnknownType] when converting VariableDescriptor #2095

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

guillaume-dequenne-sonarsource
Copy link
Contributor

@guillaume-dequenne-sonarsource guillaume-dequenne-sonarsource commented Oct 23, 2024

@guillaume-dequenne-sonarsource guillaume-dequenne-sonarsource marked this pull request as ready for review October 23, 2024 07:53
@guillaume-dequenne-sonarsource guillaume-dequenne-sonarsource changed the title SONARPY-21194 Prevent the creation of ObjectType[UnknownType] when converting VariableDescriptor SONARPY-2194 Prevent the creation of ObjectType[UnknownType] when converting VariableDescriptor Oct 24, 2024
.map(fqn -> ctx.lazyTypesContext().getOrCreateLazyTypeWrapper(fqn))
.orElse(TypeWrapper.UNKNOWN_TYPE_WRAPPER);
return new ObjectType(typeWrapper);
.map(t -> (PythonType) new ObjectType(t))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: this chain lambdas could be replaced with method references:

return Optional.ofNullable(from.annotatedType())
      .map(ctx.lazyTypesContext()::getOrCreateLazyTypeWrapper)
      .map(ObjectType::new)
      .map(PythonType.class::cast)
      .orElse(PythonType.UNKNOWN);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I hesitated between the 2 approaches and somehow preferred the one in the code (neither of them really please me though tbh...), so I'll keep it that way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor comment, feel free to ignore

@guillaume-dequenne-sonarsource guillaume-dequenne-sonarsource merged commit a95937e into master Oct 25, 2024
14 checks passed
@guillaume-dequenne-sonarsource guillaume-dequenne-sonarsource deleted the SONARPY-2194 branch October 25, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants