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

Fix type mismatch between DevTool.fromFunction() and DevTool.run() #407

Merged
merged 2 commits into from
Jun 9, 2023

Conversation

evanweible-wf
Copy link
Contributor

Motivation

The DevTool interface defines a run() method that must return FutureOr<int?>. The DevTool.fromFunction() factory expects a function with a return type of FutureOr<int>?. As a result, functions that would be valid implementations of DevTool.run() are disallowed by the typing of DevTool.fromFunction().

Changes

Update the typing of DevTool.fromFunction() to match that of DevTool.run(). The updated type is more permissive and should not be breaking. To illustrate:

FutureOr<int?> fnTest1(DevToolExecutionContext context) {}
FutureOr<int?> fnTest2(DevToolExecutionContext context) async {}
FutureOr<int>? fnTest3(DevToolExecutionContext context) {}
FutureOr<int>? fnTest4(DevToolExecutionContext context) async => 0;

void tests() {
  DevTool.fromFunction(fnTest1); // Previously a type error, now works.
  DevTool.fromFunction(fnTest2); // Previously a type error, now works.
  DevTool.fromFunction(fnTest3);
  DevTool.fromFunction(fnTest4);
}

@aviary3-wk
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

robbecker-wf
robbecker-wf previously approved these changes Jun 9, 2023
@robbecker-wf
Copy link
Member

+10

@robbecker-wf
Copy link
Member

@Workiva/release-management-p

Copy link
Contributor

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

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

+1 from RM

@rmconsole3-wf rmconsole3-wf merged commit 23b74ae into master Jun 9, 2023
@rmconsole3-wf rmconsole3-wf deleted the fix-type-mismatch-on-FunctionTool branch June 9, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants