Add a registry for SCMClient classes and move defaults into code.
Review Request #12525 — Created Aug. 10, 2022 and submitted
This introduces
rbtools.clients.base.registry.SCMClientRegistry
, which
keeps track of all the availableBaseSCMClient
subclasses. This
enables fetching a client by ID, iterating through all clients, and
registering new ones.The registry is accessible via a
rbtools.clients.scmclient_registry
instance.
SCMClient
classes should now set ascmclient_id
attribute. This will
be mandated in RBTools 5. For now, any loaded via entry point that lack
an ID will have one assigned, with a warning.To improve performance and to avoid packaging-related complications,
the default list of clients are now fully inline, rather than
introspected via entrypoints. This matches what we've been doing within
Review Board. The registry still scans entrypoints for third-party
packages, but only when needed (if listing all clients or if a lookup
fails to find it in the built-in list).Entry points use the modern
importlib.metadata.entry_points
API. This
has only solidified as of Python 3.10 (3.8/3.9 had it but it's not
compatible), so we pull in the official backport for those versions.
Unit tests pass.
Posted this change for review.
Ran
mypy
andpyright
on the new registry code, with no errors
or warnings.
Summary | ID |
---|---|
483cf2eeac0ed8377ff9c00505a31ec1a8b33f7c |
Description | From | Last Updated |
---|---|---|
local variable 'e' is assigned to but never used Column: 9 Error code: F841 |
reviewbot | |
'typing.Optional' imported but unused Column: 1 Error code: F401 |
reviewbot | |
undefined name 'RemovedInRBTools50Warning' Column: 9 Error code: F821 |
reviewbot | |
local variable 'cm' is assigned to but never used Column: 75 Error code: F841 |
reviewbot | |
local variable 'cm' is assigned to but never used Column: 75 Error code: F841 |
reviewbot |
- Change Summary:
-
- Removed unused variables.
- Removed some unused imports.
- Added a missing import.
- Commits:
-
Summary ID a479deec3cb25bd212ebed0a4f026c4f0eafb6f0 6b7a04cf9f5030e8173e5f06cb7afc7a5fd31479