Add typing annotations#592
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.
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
|
@jenkins-plone-org please run jobs |
|
@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.
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 |
|
|
2eb1c7b to
75a7796
Compare
|
@jenkins-plone-org please run jobs |
Branch: refs/heads/main Date: 2026-05-27T22:46:05+02:00 Author: ale-rt (ale-rt) <alessandro.pisa@gmail.com> Commit: plone/plone.api@62f3fc7 Clean up Backport some clean up from plone/plone.api#592 Files changed: A news/592.bugfix.md M docs/portal.md M src/plone/api/content.py M src/plone/api/portal.py M src/plone/api/tests/test_portal.py M src/plone/api/user.py Repository: plone.api Branch: refs/heads/main Date: 2026-05-28T13:35:59+02:00 Author: ale-rt (ale-rt) <alessandro.pisa@gmail.com> Commit: plone/plone.api@257aee3 fixup! Clean up Files changed: M src/plone/api/user.py Repository: plone.api Branch: refs/heads/main Date: 2026-05-28T13:39:07+02:00 Author: ale-rt (ale-rt) <alessandro.pisa@gmail.com> Commit: plone/plone.api@ef8dd61 fixup! Clean up Files changed: M src/plone/api/user.py Repository: plone.api Branch: refs/heads/main Date: 2026-05-29T09:41:44+02:00 Author: David Glick (davisagli) <david@glicksoftware.com> Commit: plone/plone.api@829547a Merge pull request #605 from plone/ale/typing-backports Clean up Files changed: A news/592.bugfix.md M docs/portal.md M src/plone/api/content.py M src/plone/api/portal.py M src/plone/api/tests/test_portal.py M src/plone/api/user.py
Branch: refs/heads/main Date: 2026-05-27T22:46:05+02:00 Author: ale-rt (ale-rt) <alessandro.pisa@gmail.com> Commit: plone/plone.api@62f3fc7 Clean up Backport some clean up from plone/plone.api#592 Files changed: A news/592.bugfix.md M docs/portal.md M src/plone/api/content.py M src/plone/api/portal.py M src/plone/api/tests/test_portal.py M src/plone/api/user.py Repository: plone.api Branch: refs/heads/main Date: 2026-05-28T13:35:59+02:00 Author: ale-rt (ale-rt) <alessandro.pisa@gmail.com> Commit: plone/plone.api@257aee3 fixup! Clean up Files changed: M src/plone/api/user.py Repository: plone.api Branch: refs/heads/main Date: 2026-05-28T13:39:07+02:00 Author: ale-rt (ale-rt) <alessandro.pisa@gmail.com> Commit: plone/plone.api@ef8dd61 fixup! Clean up Files changed: M src/plone/api/user.py Repository: plone.api Branch: refs/heads/main Date: 2026-05-29T09:41:44+02:00 Author: David Glick (davisagli) <david@glicksoftware.com> Commit: plone/plone.api@829547a Merge pull request #605 from plone/ale/typing-backports Clean up Files changed: A news/592.bugfix.md M docs/portal.md M src/plone/api/content.py M src/plone/api/portal.py M src/plone/api/tests/test_portal.py M src/plone/api/user.py
|
@jenkins-plone-org please run jobs |
davisagli
left a comment
There was a problem hiding this comment.
LGTM, assuming the jenkins builds pass
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/