{"id":17869857,"url":"https://github.com/thejaminator/slist","last_synced_at":"2026-03-08T21:06:06.385Z","repository":{"id":63952491,"uuid":"572052246","full_name":"thejaminator/slist","owner":"thejaminator","description":"A spruced up version of the built-in python list.  More post fixed methods for lovely typesafe chaining!","archived":false,"fork":false,"pushed_at":"2025-01-20T14:43:28.000Z","size":821,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-14T15:04:11.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://thejaminator.github.io/slist/","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/thejaminator.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-29T13:03:53.000Z","updated_at":"2025-01-20T14:42:50.000Z","dependencies_parsed_at":"2024-01-16T11:32:41.823Z","dependency_job_id":"8f96d6d5-7379-484e-a494-b8695bd45908","html_url":"https://github.com/thejaminator/slist","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":0.06451612903225812,"last_synced_commit":"e828472d4bfbd1b24019502f64491df1ad7a26ad"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejaminator%2Fslist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejaminator%2Fslist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejaminator%2Fslist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thejaminator%2Fslist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thejaminator","download_url":"https://codeload.github.com/thejaminator/slist/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244141577,"owners_count":20404835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-10-28T10:10:44.165Z","updated_at":"2026-03-08T21:06:01.343Z","avatar_url":"https://github.com/thejaminator.png","language":"Python","readme":"# Slist\nThis is a drop in replacement for the built-in mutable python list\n\nBut with more post-fixed methods for chaining in a typesafe manner!!\n\nLeverage the latest pyright features to spot errors during coding.\n\nAll these methods return a new list. They do not mutate the original list.\n\nNot able to convince your colleagues to use immutable functional data structures? I understand.   \nThis library lets you still have the benefits of typesafe chaining methods while letting your colleagues have their mutable lists!\n\n\n[![pypi](https://img.shields.io/pypi/v/slist.svg)](https://pypi.org/project/slist)\n[![python](https://img.shields.io/pypi/pyversions/slist.svg)](https://pypi.org/project/slist)\n[![Build Status](https://github.com/thejaminator/slist/actions/workflows/dev.yml/badge.svg)](https://github.com/thejaminator/slist/actions/workflows/dev.yml)\n\n```\npip install slist\n```\n\n\n* Documentation: \u003chttps://thejaminator.github.io/slist/\u003e\n\n\n## Quick Start\nEasily spot errors when you call the wrong methods on your sequence with mypy.\n\n```python\nfrom slist import Slist\n\nmany_strings = Slist([\"Lucy, Damion, Jon\"])  # Slist[str]\nmany_strings.sum()  # Mypy errors with 'Invalid self argument'. You can't sum a sequence of strings!\n\nmany_nums = Slist([1, 1.2])\nassert many_nums.sum() == 2.2  # ok!\n\nclass CannotSortMe:\n    def __init__(self, value: int):\n        self.value: int = value\n\nstuff = Slist([CannotSortMe(value=1), CannotSortMe(value=1)])\nstuff.sort_by(lambda x: x)  # Mypy errors with 'Cannot be \"CannotSortMe\"'. There isn't a way to sort by the class itself\nstuff.sort_by(lambda x: x.value)  # ok! You can sort by the value\n\nSlist([{\"i am a dict\": \"value\"}]).distinct_by(\n    lambda x: x\n)  # Mypy errors with 'Cannot be Dict[str, str]. You can't hash a dict itself\n```\n\nSlist provides methods to easily flatten and infer the types of your data.\n```python\nfrom slist import Slist, List\nfrom typing import Optional\n\ntest_optional: Slist[Optional[int]] = Slist([-1, 0, 1]).map(\n    lambda x: x if x \u003e= 0 else None\n)\n# Mypy infers slist[int] correctly\ntest_flattened: Slist[int] = test_optional.flatten_option()\n\n\ntest_nested: Slist[List[str]] = Slist([[\"bob\"], [\"dylan\", \"chan\"]])\n# Mypy infers slist[str] correctly\ntest_flattened_str: Slist[str] = test_nested.flatten_list()\n```\n\nThere are plenty more methods to explore!\n```python\nfrom slist import Slist\n\nresult = (\n    Slist([1, 2, 3])\n    .repeat_until_size_or_raise(20)\n    .grouped(2)\n    .map(lambda inner_list: inner_list[0] + inner_list[1] if inner_list.length == 2 else inner_list[0])\n    .flatten_option()\n    .distinct_by(lambda x: x)\n    .map(str)\n    .reversed()\n    .mk_string(sep=\",\")\n)\nassert result == \"5,4,3\"\n```\n","funding_links":[],"categories":["Awesome Functional Python"],"sub_categories":["Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthejaminator%2Fslist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthejaminator%2Fslist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthejaminator%2Fslist/lists"}