Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ commit-id = "2.2.2"
codespell_extra_lines = """
exclude: docs/locale/.*.pot
"""
extra_lines = """
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.18.2
hooks:
- id: mypy
additional_dependencies:
- types-decorator
exclude: docs
"""

[pyproject]
check_manifest_ignores = """
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ repos:
hooks:
- id: i18ndude

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.18.2
hooks:
- id: mypy
additional_dependencies:
- types-decorator
exclude: docs

##
# Add extra configuration options in .meta.toml:
Expand Down
1 change: 1 addition & 0 deletions news/+a04874c0.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add typing annotations [@ale-rt]
1 change: 1 addition & 0 deletions news/+ec620103.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
More typing annotations for the typing module
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"plone.dexterity",
"plone.i18n",
"plone.registry",
"plone.supermodel",
"plone.uuid",
"zope.globalrequest",
"Products.CMFCore",
Expand Down
10 changes: 7 additions & 3 deletions src/plone/api/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from Products.CMFPlone.interfaces import INonInstallable
from Products.CMFPlone.utils import get_installer
from Products.GenericSetup import EXTENSION
from typing import Any
from typing import cast
from typing import Dict
from typing import List
from typing import Tuple
Expand Down Expand Up @@ -98,7 +100,7 @@ def _get_non_installable_addons() -> NonInstallableAddons:


@lru_cache(maxsize=1)
def _cached_addons() -> Tuple[Tuple[str, AddonInformation]]:
def _cached_addons() -> Tuple[Tuple[str, AddonInformation], ...]:
"""Return information about add-ons in this installation.

:returns: Tuple of tuples with add-on id and AddonInformation.
Expand Down Expand Up @@ -134,7 +136,7 @@ def _cached_addons() -> Tuple[Tuple[str, AddonInformation]]:
profile_type = pid_parts[-1]
if product_id not in addons:
# get some basic information on the product
product = {
product: Dict[str, Any] = {
"id": product_id,
"version": get_version(product_id),
"title": product_id,
Expand Down Expand Up @@ -278,7 +280,9 @@ def get(addon: str) -> AddonInformation:
addons = dict(_cached_addons())
if addon not in addons:
raise InvalidParameterError(f"No add-on {addon} found.")
return _update_addon_info(addons.get(addon), _get_installer())
return _update_addon_info(
cast(AddonInformation, addons.get(addon)), _get_installer()
)


@required_parameters("addon")
Expand Down
Loading