Skip to content

Commit be035d2

Browse files
committed
Improve typing in the portal module
1 parent 69697d5 commit be035d2

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/plone/api/portal.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from email.utils import formataddr
99
from email.utils import parseaddr
1010
from logging import getLogger
11-
from plone.api._types import ContainerContext
11+
from plone.api._types import Content
1212
from plone.api._types import Request
1313
from plone.api.exc import CannotGetPortalError
1414
from plone.api.exc import InvalidParameterError
@@ -17,6 +17,7 @@
1717
from plone.registry.interfaces import IRegistry
1818
from Products.CMFCore.interfaces import ISiteRoot
1919
from Products.CMFCore.utils import getToolByName
20+
from Products.CMFPlone.Portal import PloneSite
2021
from Products.statusmessages.interfaces import IStatusMessage
2122
from typing import Any
2223
from zope.component import ComponentLookupError
@@ -60,7 +61,7 @@
6061
MISSING = object()
6162

6263

63-
def get() -> ContainerContext:
64+
def get() -> PloneSite:
6465
"""Get the Plone portal object out of thin air.
6566
6667
Without the need to import fancy Interfaces and doing multi adapter
@@ -84,9 +85,7 @@ def get() -> ContainerContext:
8485

8586

8687
@required_parameters("context")
87-
def get_navigation_root(
88-
context: ContainerContext | None = None,
89-
) -> ContainerContext:
88+
def get_navigation_root(context: Content) -> Content:
9089
"""Get the navigation root object for the context.
9190
9291
This traverses the path up and returns the nearest navigation root.
@@ -409,7 +408,7 @@ def get_default_language() -> str:
409408
return settings.default_language
410409

411410

412-
def get_current_language(context: ContainerContext | None = None) -> str:
411+
def get_current_language(context: Content | None = None) -> str:
413412
"""Return the current negotiated language.
414413
415414
:param context: context object
@@ -458,9 +457,7 @@ def translate(msgid: str, domain: str = "plone", lang: str | None = None) -> str
458457

459458

460459
@required_parameters("name")
461-
def get_vocabulary(
462-
name: str | None = None, context: ContainerContext | None = None
463-
) -> SimpleVocabulary:
460+
def get_vocabulary(name: str, context: Content | None = None) -> SimpleVocabulary:
464461
"""Return a vocabulary object with the given name.
465462
466463
:param name: Name of the vocabulary.

0 commit comments

Comments
 (0)