SDK-2488: Python - Support dark mode in IDV SDK - python#466
SDK-2488: Python - Support dark mode in IDV SDK - python#466mehmet-yoti wants to merge 2 commits into
Conversation
Extends SdkConfig and SdkConfigBuilder with two new optional fields: - dark_mode (with_dark_mode, with_dark_mode_on/off/auto convenience methods) - primary_colour_dark_mode (with_primary_colour_dark_mode) Both fields are omitted from the JSON payload when not set (None).
|
There was a problem hiding this comment.
Pull request overview
Adds dark mode theming support to the Doc Scan IDV SDK configuration by extending SdkConfig/SdkConfigBuilder with optional dark_mode and primary_colour_dark_mode fields that serialize only when set (via existing remove_null_values behavior), plus unit tests to validate defaults and JSON output.
Changes:
- Extend
SdkConfigwithdark_modeandprimary_colour_dark_modeproperties and include them into_json()(omitted whenNone). - Extend
SdkConfigBuilderwithwith_dark_mode(...)pluswith_dark_mode_on/off/auto()convenience methods, andwith_primary_colour_dark_mode(...). - Add unit tests covering defaults, builder fluency, and JSON serialization for the new fields.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
yoti_python_sdk/doc_scan/session/create/sdk_config.py |
Adds new dark mode configuration fields, builder setters, and JSON serialization support. |
yoti_python_sdk/tests/doc_scan/session/create/test_sdk_config.py |
Adds unit tests validating the new fields’ defaults and serialized payload behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| :param dark_mode: the dark mode setting | ||
| :type dark_mode: str | ||
| :return: the builder | ||
| :rtype: SdkConfigBuilder | ||
| """ |
| :param colour: the primary colour for dark mode, hexadecimal value e.g. #ff0000 | ||
| :type colour: str | ||
| :return: the builder | ||
| :rtype: SdkConfigBuilder | ||
| """ |
Code Review FindingsPR adds Minor1. The integration-style "build correctly" test already asserts every existing field on the built object but is not updated to assert # add to test_should_build_correctly
assert result.dark_mode is None
assert result.primary_colour_dark_mode is NoneNit2. No test for The existing suite has Suggested addition: def test_dark_mode_absent_from_json_when_none(self):
result = SdkConfigBuilder().with_dark_mode(None).build()
serialised = json.loads(json.dumps(result, cls=YotiEncoder))
assert "dark_mode" not in serialised
def test_primary_colour_dark_mode_absent_from_json_when_none(self):
result = SdkConfigBuilder().with_primary_colour_dark_mode(None).build()
serialised = json.loads(json.dumps(result, cls=YotiEncoder))
assert "primary_colour_dark_mode" not in serialisedNoneCritical — None |



Summary
Extends the
SdkConfigandSdkConfigBuilderclasses to support dark mode configuration in the IDV (Identity Verification) SDK. Two new optional fields —dark_modeandprimary_colour_dark_mode— are added to allow integrators to control the appearance of the web/native client in dark environments. Both fields are omitted from the JSON payload when not set, preserving backward compatibility.Changes
yoti_python_sdk/doc_scan/session/create/sdk_config.pydark_modeparameter toSdkConfig.__init__(optional, str:"ON","OFF", or"AUTO")primary_colour_dark_modeparameter toSdkConfig.__init__(optional, hex colour string)dark_modeandprimary_colour_dark_modeproperties onSdkConfigto_json()viaremove_null_values(omitted whenNone)with_dark_mode(dark_mode)generic setter onSdkConfigBuilderwith_dark_mode_on(),with_dark_mode_off(),with_dark_mode_auto()with_primary_colour_dark_mode(colour)setter onSdkConfigBuilderSdkConfigBuilder.build()to pass the two new fields toSdkConfigtests/doc_scan/session/create/test_sdk_config.pyNonevalues, each convenience method, generic setter, JSON serialisation (present and absent cases), and property accessQA Test Steps
Setup
websdk-auto/SDK-2488-python-support-dark-mode-in-idv-sdkpip install -e ".[dev]"Run the full test suite
All 502 tests should pass with no failures or errors.
Happy path — dark mode ON
Happy path — dark mode AUTO
Happy path — dark mode OFF
Edge case — fields absent when not set
Edge case — generic setter
Regression — existing SdkConfig fields unaffected
Build a
SdkConfigwith all pre-existing fields and verify JSON output is unchanged compared to before this PR.Notes
dark_modestring value; the backend is responsible for validating accepted values ("ON","OFF","AUTO"). This is consistent with how other string fields (e.g. locale, capture methods) are handled.primary_colour_dark_modefollows the same hex-colour convention asprimary_colour(no format validation in the SDK).to_json()method uses the existingremove_null_valuesutility, so no API payload changes occur when the fields are not set, maintaining full backward compatibility.DARK_MODE_ON/OFF/AUTOconstants module similar to how capture methods are defined indoc_scan/constants.py.Related Jira: SDK-2488
Auto-generated by Claude dynamic workflow