{"id":38747994,"url":"https://github.com/tompaton/pymutator","last_synced_at":"2026-01-17T11:47:37.590Z","repository":{"id":57699382,"uuid":"502338000","full_name":"tompaton/pymutator","owner":"tompaton","description":"SolidJS style updating of nested python objects","archived":false,"fork":false,"pushed_at":"2022-06-12T10:33:32.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-29T00:47:56.418Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tompaton.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-11T12:09:49.000Z","updated_at":"2022-07-20T08:16:33.000Z","dependencies_parsed_at":"2022-09-26T21:12:18.369Z","dependency_job_id":null,"html_url":"https://github.com/tompaton/pymutator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tompaton/pymutator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tompaton%2Fpymutator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tompaton%2Fpymutator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tompaton%2Fpymutator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tompaton%2Fpymutator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tompaton","download_url":"https://codeload.github.com/tompaton/pymutator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tompaton%2Fpymutator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28508459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T10:25:30.148Z","status":"ssl_error","status_checked_at":"2026-01-17T10:25:29.718Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-17T11:47:37.478Z","updated_at":"2026-01-17T11:47:37.561Z","avatar_url":"https://github.com/tompaton.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=========\nPyMutator\n=========\n\nMutate nested Python objects using a method inspired by SolidJS's\nsetState function for updating stores.\n\nhttps://www.solidjs.com/docs/latest/api#updating-stores\n\n\nExamples\n========\n\nupdate lists by index\n\n    \u003e\u003e\u003e from pymutator import mutate\n    \u003e\u003e\u003e mutate([1, 2, 3, 4, 5], 3, 'D')\n    [1, 2, 3, 'D', 5]\n\nupdate lists by list of indices\n\n    \u003e\u003e\u003e mutate([1, 2, 3, 4, 5], [1, 3], 'D')\n    [1, 'D', 3, 'D', 5]\n\nupdate lists by filter predicate\n\n    \u003e\u003e\u003e mutate([1, 2, 3, 4, 5], lambda i: i%2, 'odd')\n    ['odd', 2, 'odd', 4, 'odd']\n\nupdate list with computed value\n\n    \u003e\u003e\u003e mutate([1, 2, 3, 4, 5], 3, lambda i: f'D{i}')\n    [1, 2, 3, 'D4', 5]\n\nupdate dict\n\n    \u003e\u003e\u003e mutate({'a': 1, 'b': 2, 'c': 3}, 'b', 'B')\n    {'a': 1, 'b': 'B', 'c': 3}\n\n    \u003e\u003e\u003e mutate({'a': 1, 'b': 2, 'c': 3}, b='B')\n    {'a': 1, 'b': 'B', 'c': 3}\n\n    \u003e\u003e\u003e mutate({'a': 1, 'b': 2, 'c': 3}, {'b': 'B'})\n    {'a': 1, 'b': 'B', 'c': 3}\n\n    \u003e\u003e\u003e mutate({'a': 1, 'b': 2, 'c': 3}, ['b', 'x'], 'B')\n    {'a': 1, 'b': 'B', 'c': 3, 'x': 'B'}\n\nupdate dict with filter predicate\n\n    \u003e\u003e\u003e mutate({'a': 1, 'b': 2, 'c': 3}, lambda i: i%2, 'odd')\n    {'a': 'odd', 'b': 2, 'c': 'odd'}\n\nupdate dict with computed value\n\n    \u003e\u003e\u003e mutate({'a': 1, 'b': 2, 'c': 3}, 'b', lambda i: f'B{i}')\n    {'a': 1, 'b': 'B2', 'c': 3}\n\nupdate object\n\n    \u003e\u003e\u003e class O:\n    ...     def __init__(self): self.a = 1\n    \u003e\u003e\u003e o = O()\n    \u003e\u003e\u003e mutate(o, 'a', 2) and o.a\n    2\n\n    \u003e\u003e\u003e mutate(o, a=3) and o.a\n    3\n\n    \u003e\u003e\u003e mutate(o, {'a': 4}) and o.a\n    4\n\n    \u003e\u003e\u003e mutate(o, 'a', lambda i: i+1) and o.a\n    5\n\nupdating nested objects\n\n    \u003e\u003e\u003e store = {\n    ...    'todos': [\n    ...            {'task': 'Finish work', 'completed': False},\n    ...            {'task': 'Go grocery shopping', 'completed': False},\n    ...            {'task': 'Make dinner', 'completed': False},\n    ...        ]\n    ...    }\n\n    \u003e\u003e\u003e mutate(store, 'todos', [0, 2], 'completed', True)\n    {'todos': [{'task': 'Finish work', 'completed': True}, {'task': 'Go grocery shopping', 'completed': False}, {'task': 'Make dinner', 'completed': True}]}\n\n    \u003e\u003e\u003e mutate(store, 'todos', lambda todo: todo['completed'],\n    ...        'task', lambda t: t + '!')\n    {'todos': [{'task': 'Finish work!', 'completed': True}, {'task': 'Go grocery shopping', 'completed': False}, {'task': 'Make dinner!', 'completed': True}]}\n\n\nRunning tests\n=============\n\n::\n\n    $ pytest\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftompaton%2Fpymutator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftompaton%2Fpymutator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftompaton%2Fpymutator/lists"}