8000 Introduce Pydantic data models and API type annotations by Sab44 · Pull Request #4560 · pyload/pyload · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Introduce Pydantic data models and API type annotations #4560

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

Draft
wants to merge 27 commits into
base: develop
Choose a base branch
from

Conversation

Sab44
Copy link
@Sab44 Sab44 commented Mar 24, 2025

Describe the changes

As outlined in my comment on #4414 this is the first step to enable automatic API documentation.

  • All API methods are type annotated, both parameters and return types
  • All non-primitive data types are moved to Pydantic models for automatic validation

So far, everything seems to work just fine.

With this, we can parse the existing methods into an OpenAPI specificaton, will submit this in a follow-up PR. I have a working draft, but it needs some polishing.

I've tried to encapsulate all changes to logical commits to make the review easier. In any case, I'd say this should probably stay on the develop branch for a couple of weeks before merging into main to make sure it doesn't cause any issues.

Additional references

Related issue #4414

@CLAassistant
Copy link
CLAassistant commented Mar 24, 2025

CLA assistant check
All committers have signed the CLA.

@@ -1215,15 +1236,15 @@ def get_account_types(self):

@legacy("updateAccount")
@permission(Perms.ACCOUNTS)
def update_account(self, plugin, account, password=None, options={}):
def update_account(self, plugin: str, account: str, password: str = None, options: dict[str: Any] = {}) -> None:
Copy link
Author

Choose a reason for hiding this comment

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

I understand the code analysis is throwing a warning here, but I think for now we should keep the default arguments as they were before.

@Sab44 Sab44 mentioned this pull request Mar 25, 2025
except Exception:
return jsonify(False), 500


Copy link
Author

Choose a reason for hiding this comment

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

I deleted this function because I don't think it actually worked.

it calls get_queue() which returns PackageData and then tries to access it id - but PackageData has no id property/key.
Even if we assume that pid was meant here, then it will call api.get_package_files() which doesn't exist.

So something was very broken here. If you think we should keep it then please let me know how to fix this method to actually work as expected.

@GammaC0de GammaC0de marked this pull request as draft March 28, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0