Skip to main content

Call a function, and pass it only the arguments it expects.

Project description

SmartCall

Last release Python version Documentation Test status Test coverage Last commit

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartcall-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smartcall-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

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

Hashes for smartcall-0.1.0.tar.gz
Algorithm Hash digest
SHA256 440599751a67cf73f984eb9f7eab82d3064a893e9e1fdcd93a4af3ae5c37288e
MD5 ca82f1d0a5fb7ea881bec4cbde7a76ab
BLAKE2b-256 d45e830712b818df09ffb2cbc5d4a98868141d8d71a0628d81ae1aaced0b0014

See more details on using hashes here.

Provenance

The following attestation bundles were made for smartcall-0.1.0.tar.gz:

Publisher: release.yml on kalekundert/smartcall

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for smartcall-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af88462179e79593750339e2b6d5200319b8ad56817bc66a39638386a160b5c6
MD5 6ba85c1498644e85484ee1a2c5922f7a
BLAKE2b-256 3c314b117162911683876ec9be1e66e5969c10423ff377ebd78f55c1922ab1e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for smartcall-0.1.0-py3-none-any.whl:

Publisher: release.yml on kalekundert/smartcall

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page