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 hinting for automatic run inputs #11796

Merged
merged 1 commit into from
Feb 1, 2024
Merged

Conversation

bunchesofdonald
Copy link
Contributor

@bunchesofdonald bunchesofdonald commented Jan 31, 2024

This fixes the type hinting for automatic run inputs. Previously if you passed a str or anything else that wasn't a RunInput subclass into pause_flow_run or receive_input the type hint would come back as Any. This makes it so that those hints are accurate.

There is one caveat to this, if you pass in a pydantic model:

class MyModel(pydantic.BaseModel):
    name: str
    value: str

...
    input = await receive_input(MyModel).next()

input in this case will be hinted as a MyModel instance, which is technically inaccurate. input will be a subclass of RunInput and MyModel. I chose to go this route rather than hinting that it was a generic RunInput class, but could be convinced that it makes sense the other way.

Closes #11792

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • This pull request includes tests or only affects documentation.
  • This pull request includes a label categorizing the change e.g. maintenance, fix, feature, enhancement, docs.

For documentation changes:

  • This pull request includes redirect settings in netlify.toml for files that are removed or renamed.

For new functions or classes in the Python SDK:

  • This pull request includes helpful docstrings.
  • If a new Python file was added, this pull request contains a stub page in the Python SDK docs and an entry in mkdocs.yml navigation.

@bunchesofdonald bunchesofdonald added the enhancement An improvement of an existing feature label Jan 31, 2024
@bunchesofdonald bunchesofdonald requested a review from a team as a code owner January 31, 2024 22:05
Copy link

netlify bot commented Jan 31, 2024

Deploy Preview for prefect-docs-preview ready!

Name Link
🔨 Latest commit fd4b7b5
🔍 Latest deploy log https://app.netlify.com/sites/prefect-docs-preview/deploys/65bbb4e00f96930008d3103f
😎 Deploy Preview https://deploy-preview-11796--prefect-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@abrookins abrookins left a comment

Choose a reason for hiding this comment

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

I'm good with this! 👍

@bunchesofdonald bunchesofdonald merged commit eab65a4 into main Feb 1, 2024
61 checks passed
@bunchesofdonald bunchesofdonald deleted the issue-11792 branch February 1, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix typing for automatic inputs
2 participants