{"record":{"id":"3c075eebf3aa4099","repo":"deepfakes/faceswap","slug":"dataclass-params-sorted-required-should-be-a-su","errorCode":null,"errorMessage":"Dataclass params {sorted(required)} should be a subset of dictionary keys {sorted(inbound)}","messagePattern":"Dataclass params (.+?) should be a subset of dictionary keys (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/align/objects.py","lineNumber":178,"sourceCode":"\n    @classmethod\n    def from_dict(cls, data_dict: dict[str, T.Any]) -> T.Self:\n        \"\"\"Load the contents from a serialized python dict into this dataclass\n\n        Parameters\n        ----------\n        data_dict\n            The data to load into the dataclass\n        \"\"\"\n        inbound = set(data_dict)\n        all_fields = set(f.name for f in fields(cls))\n        required = set(f.name for f in fields(cls)\n                       if f.default is MISSING and f.default_factory is MISSING)\n        if not inbound.issubset(all_fields):\n            raise ValueError(f\"Dictionary keys {sorted(inbound)} should be a subset of dataclass \"\n                             f\"params {sorted(all_fields)}\")\n        if not required.issubset(inbound):\n            raise ValueError(f\"Dataclass params {sorted(required)} should be a subset of \"\n                             f\"dictionary keys {sorted(inbound)}\")\n        type_hints = T.get_type_hints(cls)\n        kwargs: dict[str, T.Any] = {}\n        for f in fields(cls):\n            if f.name not in data_dict:\n                continue\n            field_type = type_hints.get(f.name)\n            val = data_dict[f.name]\n            converted = cls._convert_dtype(field_type, val)\n            if converted is not None:\n                kwargs[f.name] = converted\n                continue\n            if isinstance(val, dict):\n                kwargs[f.name] = cls._parse_dict(field_type, val)\n                continue\n            if isinstance(val, (list, tuple)):\n                kwargs[f.name] = cls._parse_list(field_type, val)\n                continue","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/deepfakes/faceswap/blob/f530cb7508ae670f6474f8a7d9c4df94705cf96b/lib/align/objects.py#L160-L196","documentation":"Faceswap's GUI is TkInter-based. When the 'gui' command is requested, lib/cli/launcher.py tries `import tkinter`; on ImportError it logs per-OS install hints and re-raises as FaceswapError('TkInter not found').","triggerScenarios":"Running `faceswap.py gui` (or python faceswap.py with no args, which defaults to GUI) in a Python environment where the tkinter module is not installed (missing tk package, headless python build, some conda/miniconda images).","commonSituations":"Docker/CI images built on python:slim which omit tk; minimal Linux python installs; a conda env created without tk; macOS system python without ActiveTcl.","solutions":["Install tk for your platform: Ubuntu/Debian `sudo apt install python3-tk`, Arch `sudo pacman -S tk`, Fedora `sudo dnf install python3-tkinter`, conda `conda install tk`","If you don't need the GUI, run a CLI command explicitly (e.g. `python faceswap.py extract ...`) instead of GUI mode","Verify with `python -c \"import tkinter\"` in the same interpreter/env you launch faceswap with"],"exampleFix":"# before\npython faceswap.py          # launches GUI -> FaceswapError: TkInter not found\n\n# after (Ubuntu/Debian)\nsudo apt install python3-tk\npython faceswap.py\n# or skip the GUI entirely\npython faceswap.py extract --help","handlingStrategy":"validation","validationCode":"from dataclasses import fields\n\nfrom dataclasses import fields, MISSING\n\ndef missing_required(cls, data):\n    req = {f.name for f in fields(cls)\n           if f.default is MISSING and f.default_factory is MISSING}\n    return req - set(data)\n\nmissing = missing_required(MyDataclass, payload)\nassert not missing, f\"payload lacks: {missing}\"","typeGuard":null,"tryCatchPattern":"try:\n    obj = MyDataclass.from_dict(payload)\nexcept ValueError as err:\n    if \"should be a subset of dictionary keys\" in str(err):\n        for k in missing_required(MyDataclass, payload):\n            payload[k] = DEFAULTS[k]\n        obj = MyDataclass.from_dict(payload)\n    else:\n        raise","preventionTips":["Migrate old alignments files with the supported version before loading","Write round-trip tests that serialize then from_dict every dataclass","Keep a DEFAULTS map per dataclass to fill newly added required fields"],"tags":["faceswap","gui","tkinter","environment","installation"],"backgroundTag":null,"analyzedSha":"f530cb7508ae670f6474f8a7d9c4df94705cf96b","analyzedAt":"2026-08-15T02:59:26.626Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}