Skip to content

Type annotations, package reorganization, identity export/import, and coverage#115

Merged
ericof merged 7 commits into
mainfrom
issue-111
Jul 11, 2026
Merged

Type annotations, package reorganization, identity export/import, and coverage#115
ericof merged 7 commits into
mainfrom
issue-111

Conversation

@ericof

@ericof ericof commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

A large modernization pass on the add-on: full type annotations, a package reorganization following cookieplone conventions, new user-identity export/import helpers, a better default user-id factory, and a substantial increase in test coverage.

Changes

Typing (#111)

  • Annotated the full src tree and shipped a py.typed marker (PEP 561).
  • Structural Protocols (AuthResult/AuthUser/AuthProvider) for the untyped authomatic surface and TypedDicts for the mappings.
  • make typecheck (mypy) target wired into make check and CI (check-typing: true).

Package reorganization (#112)

  • Promoted utils to a package (content/plugin/request/settings), split useridfactories into a package, added vocabularies and a config module.
  • Slimmed interfaces down to interface definitions; modernized IPloneSiteRoot/request (WSGIRequest) imports.
  • Greatly expanded test coverage across the add-on, including the browser view (~29% → 97%).

Export/import user identities (#113)

  • export_plugin_data / import_plugin_data helpers to serialize the plugin's user identities to JSON and restore them, for site migrations.
  • Documented in the README with runnable examples.

Default user-id factory (#114)

  • Default userid_factory_name changed from uuid to username_userid for deterministic, human-meaningful ids. Existing sites keep their configured value.

Testing

make check (lint + format + mypy) and the full suite pass — 144 tests, green on Plone 6.1/6.2 × Python 3.11–3.14.

Closes

Closes #111
Closes #112
Closes #113
Closes #114

ericof added 7 commits July 11, 2026 10:23
- Annotate the full src tree (utils, useridentities, useridfactories,
  plugin, services, integration, browser) and ship a py.typed marker.
- Introduce structural Protocols (AuthResult/AuthUser/AuthProvider) for
  the untyped authomatic surface and TypedDicts for the mappings.
- Make authomatic_cfg always return a dict, dropping the None checks.
- Add a make typecheck target (mypy) wired into make check.
- Modernize setuphandlers to use plone.api and plone.base INonInstallable.

Closes #111
Promote utils to a package (content/plugin/request/settings), split
useridfactories into a package, add vocabularies and a config module,
and slim interfaces down to interface definitions. Modernize the
IPloneSiteRoot and request (WSGIRequest) imports, and enable typing
checks in CI.

Refs #112
Add tests for the utils subpackages, the user-id factories and their
dispatcher, the vocabularies, the REST and Zope request adapters, and
the config validator, mirroring the new package layout.

Refs #112
Add export_plugin_data / import_plugin_data helpers to serialize the
plugin's user identities to a JSON file and restore them, for use
during site migrations. UserIdentity/UserIdentities gain from_dict
classmethods to rebuild persistent objects from exported data, and a
dependencies.zcml loads plone.restapi so json_compatible is available.

Closes #113
Deterministic, human-meaningful user ids are easier to target with
permissions and group assignments than random UUIDs. Only affects new
installations; existing sites keep their configured value.

Closes #114
Cover AuthomaticView: config caching, provider listing, publishTraverse,
the identity delegation helpers, and the __call__ branches (config
errors, non-root redirect, provider validation, and the anonymous login
flow). Raises view.py coverage from ~29% to 97%.

Refs #112
- Add 'from __future__ import annotations' to modules using TYPE_CHECKING
  imports (utils/plugin, useridfactories/*); without it, the annotations
  were evaluated at import time and raised NameError on Python < 3.14
  (3.14 defers annotation evaluation by default, which masked it locally).
- Declare mypy as a test dependency so the CI 'uv run mypy src' step runs.
- Configure mypy for the PEP 420 native namespace (explicit_package_bases,
  namespace_packages, mypy_path) to avoid a 'found twice' clash with the
  installed authomatic distribution.
- Fix the two real type errors this surfaced (list_providers accumulator
  type; _properties_from_identity cfg is a ProviderConfig).
@ericof ericof merged commit 815d85c into main Jul 11, 2026
12 checks passed
@ericof ericof deleted the issue-111 branch July 11, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant