Skip to content

Commit b4b10be

Browse files
committed
Add typing annotations
1 parent 216a607 commit b4b10be

20 files changed

Lines changed: 359 additions & 123 deletions

.meta.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ commit-id = "2.9.0"
99
codespell_extra_lines = """
1010
exclude: docs/locale/.*.pot
1111
"""
12+
extra_lines = """
13+
- repo: https://github.com/pre-commit/mirrors-mypy
14+
rev: v1.18.2
15+
hooks:
16+
- id: mypy
17+
additional_dependencies:
18+
- types-decorator
19+
exclude: docs
20+
"""
1221

1322
[pyproject]
1423
check_manifest_ignores = """
@@ -23,7 +32,7 @@ check_manifest_ignores = """
2332
"requirements-docs.txt",
2433
"requirements.txt",
2534
"""
26-
dependencies_ignores = "['Products.PrintingMailHost', 'plone.app.iterate',]"
35+
dependencies_ignores = "['Products.DCWorkflow', 'Products.PrintingMailHost', 'plone.app.iterate',]"
2736
codespell_ignores = "manuel,checkin"
2837

2938
[tox]

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ repos:
8585
# """
8686
##
8787

88+
- repo: https://github.com/pre-commit/mirrors-mypy
89+
rev: v1.18.2
90+
hooks:
91+
- id: mypy
92+
additional_dependencies:
93+
- types-decorator
94+
exclude: docs
8895

8996
##
9097
# Add extra configuration options in .meta.toml:

news/+a04874c0.internal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add typing annotations [@ale-rt]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Zope = [
124124
]
125125
python-dateutil = ['dateutil']
126126
pytest-plone = ['pytest', 'zope.pytestlayer', 'plone.testing', 'plone.app.testing']
127-
ignore-packages = ['Products.PrintingMailHost', 'plone.app.iterate',]
127+
ignore-packages = ['Products.DCWorkflow', 'Products.PrintingMailHost', 'plone.app.iterate',]
128128

129129
##
130130
# Add extra configuration options in .meta.toml:

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"plone.dexterity",
3737
"plone.i18n",
3838
"plone.registry",
39+
"plone.supermodel",
3940
"plone.uuid",
4041
"zope.globalrequest",
4142
"Products.CMFCore",

src/plone/api/addon.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from plone.base.utils import get_installer
1212
from Products.CMFPlone.controlpanel.browser.quickinstaller import InstallerView
1313
from Products.GenericSetup import EXTENSION
14+
from typing import Any
1415
from zope.component import getAllUtilitiesRegisteredFor
1516
from zope.globalrequest import getRequest
1617

@@ -94,7 +95,7 @@ def _get_non_installable_addons() -> NonInstallableAddons:
9495

9596

9697
@lru_cache(maxsize=1)
97-
def _cached_addons() -> tuple[tuple[str, AddonInformation]]:
98+
def _cached_addons() -> tuple[tuple[str, AddonInformation], ...]:
9899
"""Return information about add-ons in this installation.
99100
100101
:returns: Tuple of tuples with add-on id and AddonInformation.
@@ -130,7 +131,7 @@ def _cached_addons() -> tuple[tuple[str, AddonInformation]]:
130131
profile_type = pid_parts[-1]
131132
if product_id not in addons:
132133
# get some basic information on the product
133-
product = {
134+
product: dict[str, Any] = {
134135
"id": product_id,
135136
"version": get_version(product_id),
136137
"title": product_id,
@@ -271,10 +272,10 @@ def get(addon: str) -> AddonInformation:
271272
:returns: Add-on information.
272273
:rtype: string
273274
"""
274-
addons = dict(_cached_addons())
275+
addons: dict[str, AddonInformation] = dict(_cached_addons())
275276
if addon not in addons:
276277
raise InvalidParameterError(f"No add-on {addon} found.")
277-
return _update_addon_info(addons.get(addon), _get_installer())
278+
return _update_addon_info(addons[addon], _get_installer())
278279

279280

280281
@required_parameters("addon")

0 commit comments

Comments
 (0)