-
-
Notifications
You must be signed in to change notification settings - Fork 58
Add typing annotations #592
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
base: main
Are you sure you want to change the base?
Conversation
|
@ale-rt thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment: To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically. Happy hacking! |
| def get_localized_time(datetime=None, long_format=False, time_only=False): | ||
| def get_localized_time( | ||
| datetime: Optional[Union[date, DateTime, datetime]] = None, | ||
| long_format: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exposes an incorrect behavior of this method as long_format can also be a custom string
https://github.com/plone/plone.base/blob/18f2f4c7ca24da0d6b26bf9c25a061c7cf3ec037/src/plone/base/i18nl10n.py#L221-L224
Initial draft courtesy of `monkeytype`: ```shell .venv/bin/uv pip install -e plone.api[test] monkeytype zope.testrunner monkeytype run .venv/bin/zope-testrunner --path plone.api/src/ for module in `monkeytype list-modules`; do monkeytype apply $module || true > /dev/null;done ```
|
@jenkins-plone-org please run jobs |
More typing annotations for the content module
|
@jenkins-plone-org please run jobs |
|
@ale-rt Take a look at https://github.com/plone/plone-stubs. The current state already support plone.api and it should be in a decent state. |
|
@jenkins-plone-org please run jobs |
Thanks, I checked it, yet I believe this is an improvement worth to be merged. |
davisagli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will take some time to review carefully.
For a start, at first glance, I see lots of annotations with ImplicitAcquisitionWrapper that look wrong. Those are usually meant to be a DexterityContent, and I think monkeytype was confused by the acquisition wrapper.
It does not look wrong to me: >>> isinstance(api.portal.get(), ImplicitAcquisitionWrapper)
TrueI think it is way worse to use in the annotation |
|
@ale-rt Right now, all content types we have are Dexterity based. I understand your point of using |
|
Most of these APIs are designed specifically to work with content objects, not any acquisition-wrapped Python object. So using ImplicitAcquisitionWrapper still seems quite wrong to me. |
Autocomplete in the IDE is not the point of this PR, IMO. Most probably you will anyway end up with code like: obj: Document = api.content.get(UID="...")
view: PloneView = api.content.get_view("plone") |
To me it seems wrong to say it returns a dexterity content :D |
|
|
Initial draft courtesy of
monkeytype:If your pull request closes an open issue, include the exact text below, immediately followed by the issue number. When your pull request gets merged, then that issue will close automatically.
Closes #
📚 Documentation preview 📚: https://ploneapi--592.org.readthedocs.build/