{"id":18084872,"url":"https://github.com/jwodder/argset","last_synced_at":"2025-07-20T17:04:20.969Z","repository":{"id":57411512,"uuid":"373981462","full_name":"jwodder/argset","owner":"jwodder","description":"Simple callable argument inspection \u0026 filtering","archived":false,"fork":false,"pushed_at":"2025-01-23T14:07:38.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-16T13:05:28.959Z","etag":null,"topics":["arguments","available-on-pypi","callable","inspect","keyword-arguments","python","signature"],"latest_commit_sha":null,"homepage":"","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/jwodder.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"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":"2021-06-04T23:36:09.000Z","updated_at":"2025-02-01T18:58:03.000Z","dependencies_parsed_at":"2023-01-31T01:55:13.945Z","dependency_job_id":"ed4af23d-cb7c-45f2-b707-9886449219d5","html_url":"https://github.com/jwodder/argset","commit_stats":{"total_commits":35,"total_committers":1,"mean_commits":35.0,"dds":0.0,"last_synced_commit":"295e998ad38b56bef63ee3c327298168d9802663"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jwodder/argset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fargset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fargset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fargset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fargset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwodder","download_url":"https://codeload.github.com/jwodder/argset/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwodder%2Fargset/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266161900,"owners_count":23885927,"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":["arguments","available-on-pypi","callable","inspect","keyword-arguments","python","signature"],"created_at":"2024-10-31T15:08:28.441Z","updated_at":"2025-07-20T17:04:20.950Z","avatar_url":"https://github.com/jwodder.png","language":"Python","readme":"|repostatus| |ci-status| |coverage| |pyversions| |license|\n\n.. |repostatus| image:: https://www.repostatus.org/badges/latest/active.svg\n    :target: https://www.repostatus.org/#active\n    :alt: Project Status: Active — The project has reached a stable, usable\n          state and is being actively developed.\n\n.. |ci-status| image:: https://github.com/jwodder/argset/actions/workflows/test.yml/badge.svg\n    :target: https://github.com/jwodder/argset/actions/workflows/test.yml\n    :alt: CI Status\n\n.. |coverage| image:: https://codecov.io/gh/jwodder/argset/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/jwodder/argset\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/argset.svg\n    :target: https://pypi.org/project/argset/\n\n.. |license| image:: https://img.shields.io/github/license/jwodder/argset.svg\n    :target: https://opensource.org/licenses/MIT\n    :alt: MIT License\n\n`GitHub \u003chttps://github.com/jwodder/argset\u003e`_\n| `PyPI \u003chttps://pypi.org/project/argset/\u003e`_\n| `Issues \u003chttps://github.com/jwodder/argset/issues\u003e`_\n| `Changelog \u003chttps://github.com/jwodder/argset/blob/master/CHANGELOG.md\u003e`_\n\n``argset`` provides a simple interface for determining whether a callable takes\nan argument with a given name, filtering a ``dict`` of potential arguments down\nto just those that a callable accepts, and determining any required arguments\nthat are missing from a ``dict`` of potential arguments.\n\nInstallation\n============\n``argset`` requires Python 3.8 or higher.  Just use `pip\n\u003chttps://pip.pypa.io\u003e`_ for Python 3 (You have pip, right?) to install\n``argset`` and its dependencies::\n\n    python3 -m pip install argset\n\n\nExamples\n========\n\nInspecting a function's arguments::\n\n    \u003e\u003e\u003e from argset import argset\n    \u003e\u003e\u003e def my_func(foo, bar):\n    ...     print(f\"foo={foo!r}\")\n    ...     print(f\"bar={bar!r}\")\n    ...\n    \u003e\u003e\u003e a = argset(my_func)\n    \u003e\u003e\u003e \"foo\" in a\n    True\n    \u003e\u003e\u003e \"quux\" in a\n    False\n\nFiltering a set of arguments to just those accepted by the function::\n\n    \u003e\u003e\u003e a.select({\"foo\": 42, \"bar\": 23, \"quux\": 17})\n    {'foo': 42, 'bar': 23}\n    \u003e\u003e\u003e my_func(**a.select({\"foo\": 42, \"bar\": 23, \"quux\": 17}))\n    foo=42\n    bar=23\n\nSame as above, but now the function takes ``**kwargs``::\n\n    \u003e\u003e\u003e from argset import argset\n    \u003e\u003e\u003e def my_func2(foo, **kwargs):\n    ...     print(f\"foo={foo!r}\")\n    ...     for k, v in kwargs.items():\n    ...          print(f\"{k}={v!r}\")\n    ...\n    \u003e\u003e\u003e a2 = argset(my_func2)\n    \u003e\u003e\u003e \"foo\" in a2\n    True\n    \u003e\u003e\u003e \"quux\" in a2\n    True\n    \u003e\u003e\u003e a2.select({\"foo\": 42, \"bar\": 23, \"quux\": 17})\n    {'foo': 42, 'bar': 23, 'quux': 17}\n    \u003e\u003e\u003e my_func2(**a2.select({\"foo\": 42, \"bar\": 23, \"quux\": 17}))\n    foo=42\n    bar=23\n    quux=17\n\n\nAPI\n===\n\n.. code:: python\n\n    argset(func: Callable) -\u003e ArgSet\n\nInspects a callable and returns a summary of its arguments as an ``ArgSet``\n\n.. code:: python\n\n    class ArgSet\n\nA representation of the arguments taken by a callable.  It has the following\nattributes \u0026 properties:\n\n``required_positional_only: int``\n    The number of arguments that are positional-only and do not have default\n    values\n\n``optional_positional_only: int``\n    The number of arguments that are positional-only and have a default value\n\n``positional_only: int``\n    The total number of positional-only arguments\n\n``required_args: frozenset[str]``\n    The names of all positional-or-keyword or keyword-only arguments that do\n    not have default values\n\n``optional_args: frozenset[str]``\n    The names of all positional-or-keyword or keyword-only arguments that have\n    default values\n\n``argnames: frozenset[str]``\n    The names of all positional-or-keyword or keyword-only arguments\n\n``takes_args: bool``\n    Whether the callable has an argument of the form ``*args``\n\n``takes_kwargs: bool``\n    Whether the callable has an argument of the form ``**kwargs``\n\n``ArgSet`` objects support the ``in`` operator; an expression of the form\n``argname in a`` returns ``True`` iff ``argname`` is in ``a.argnames`` or\n``a.takes_kwargs`` is ``True``.\n\n``ArgSet`` objects have the following methods:\n\n.. code:: python\n\n    ArgSet.select(kwargs: Dict[str, Any]) -\u003e Dict[str, Any]\n\nReturns all items in ``kwargs`` where the key is the name of a\npositional-or-keyword or keyword-only argument accepted by the callable.  If\n``takes_kwargs`` is ``True``, the return value is a copy of ``kwargs``.\n\n.. code:: python\n\n    ArgSet.missing(kwargs: Dict[str, Any]) -\u003e FrozenSet[str]\n\nReturns all keys in ``required_args`` that do not appear in ``kwargs``\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwodder%2Fargset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwodder%2Fargset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwodder%2Fargset/lists"}