8000 Add deprecated field to Input by 8W9aG · Pull Request #2360 · replicate/cog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add deprecated field to Input #2360

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

Merged
merged 1 commit into from
May 23, 2025
Merged

Add deprecated field to Input #2360

merged 1 commit into from
May 23, 2025

Conversation

8W9aG
Copy link
Contributor
@8W9aG 8W9aG commented May 23, 2025
  • Allow inputs to be marked as deprecated
  • If they are, declare them deprecated in the openapi schema

* Allow inputs to be marked as deprecated
* If they are, declare them deprecated in the
openapi schema
@@ -73,6 +73,7 @@ def Input( # pylint: disable=invalid-name, too-many-arguments
max_length: Optional[int] = None,
regex: Optional[str] = None,
choices: Optional[List[Union[str, int]]] = None,
deprecated: Optional[bool] = None,
Copy link
Member
@erbridge erbridge May 23, 2025

Choose a reason for hiding this comment

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

Does this need to be optional? Couldn't it be this?

Suggested change
deprecated: Optional[bool] = None,
deprecated: bool = False,

and only set field_kwargs["deprecated"] at all if it's True?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather it be Optional to minimise the impact to the openapi schema unless the user wants to explicitly declare the deprecation

Copy link
Member

Choose a reason for hiding this comment

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

That's what I mean, too. Only ever set field_kwargs["deprecated"] = True if deprecated == True, otherwise, treat False like you currently treat None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think Optional captures this behaviour in a clearer way, only writing the new field if it is explicitly invoked by the user.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough

@8W9aG 8W9aG merged commit e5c83e7 into main May 23, 2025
26 checks passed
@8W9aG 8W9aG deleted the sackfield/add-deprecated-input branch May 23, 2025 17:44
@zeke zeke mentioned this pull request May 27, 2025
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
0