Call a function, and pass it only the arguments it expects.
Project description
SmartCall
This library provides a way to call functions that won't necessarily accept all of the arguments that you could pass to them. This situation often occurs when writing libraries that accept callback functions. The library might have lots of information that it could pass to callbacks, but not every callback will want every piece of information.
The following snippet shows how the library works. As an example, we'll invoke a callback with one required positional argument and two optional keyword arguments. Note that the callback only accepts the first keyword argument:
>>> from smartcall import call, PosOnly, KwOnly
>>> def my_callback(a, b):
... return a, b
...
>>> call(
... my_callback,
...
... # This argument is required, so if the callback can't accept it, an
... # error will be raised.
... PosOnly(1, required=True), KwOnly('b', 2))
...
... # These arguments are not required, so they will only be passed to the
... # callback if it has a compatible signature.
... KwOnly(b=2),
... KwOnly(c=3),
... )
(1, 2)
Refer to the online documentation for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smartcall-0.1.0.tar.gz.
File metadata
- Download URL: smartcall-0.1.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
440599751a67cf73f984eb9f7eab82d3064a893e9e1fdcd93a4af3ae5c37288e
|
|
| MD5 |
ca82f1d0a5fb7ea881bec4cbde7a76ab
|
|
| BLAKE2b-256 |
d45e830712b818df09ffb2cbc5d4a98868141d8d71a0628d81ae1aaced0b0014
|
Provenance
The following attestation bundles were made for smartcall-0.1.0.tar.gz:
Publisher:
release.yml on kalekundert/smartcall
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smartcall-0.1.0.tar.gz -
Subject digest:
440599751a67cf73f984eb9f7eab82d3064a893e9e1fdcd93a4af3ae5c37288e - Sigstore transparency entry: 168742754
- Sigstore integration time:
-
Permalink:
kalekundert/smartcall@ee47d5344001457d778719388f43519878fa778a -
Branch / Tag:
refs/heads/master - Owner: https://github.com/kalekundert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ee47d5344001457d778719388f43519878fa778a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file smartcall-0.1.0-py3-none-any.whl.
File metadata
- Download URL: smartcall-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af88462179e79593750339e2b6d5200319b8ad56817bc66a39638386a160b5c6
|
|
| MD5 |
6ba85c1498644e85484ee1a2c5922f7a
|
|
| BLAKE2b-256 |
3c314b117162911683876ec9be1e66e5969c10423ff377ebd78f55c1922ab1e2
|
Provenance
The following attestation bundles were made for smartcall-0.1.0-py3-none-any.whl:
Publisher:
release.yml on kalekundert/smartcall
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smartcall-0.1.0-py3-none-any.whl -
Subject digest:
af88462179e79593750339e2b6d5200319b8ad56817bc66a39638386a160b5c6 - Sigstore transparency entry: 168742770
- Sigstore integration time:
-
Permalink:
kalekundert/smartcall@ee47d5344001457d778719388f43519878fa778a -
Branch / Tag:
refs/heads/master - Owner: https://github.com/kalekundert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ee47d5344001457d778719388f43519878fa778a -
Trigger Event:
workflow_dispatch
-
Statement type: