Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Better signature tests for required arguments

Open
#281 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
testing

Research direction

Start by locating the signature tests and the specified_kwargs() helper mentioned in the issue, then run their existing tests to understand current behavior. Done means signatures with extra required positional arguments fail, while optional positional arguments are tested both positionally and by keyword.

Written by the indexing model from the issue text.

Description

medium priority

This signature tests do not properly check for cases where a function has more required positional arguments than it should. Such a case should be considered noncompliant, since user code written against the standard signature would not function. For example, if the standard has a function

def f(x, y=None):
    ...

then a function

def f(x, y):
    ...

should fail the signature test, because code like f(a) should work according to the standard but it wouldn't in the implementation.

Practically speaking, this would help me catch bugs with the xp signature logic in array-api-compat (see https://data-apis.org/array-api-compat/dev/implementation-notes.html). For instance, I accidentally wrote

def clip(
    x: ndarray,
    /,
	xp,
    min: Optional[Union[int, float, ndarray]] = None,
    max: Optional[Union[int, float, ndarray]] = None,
) -> ndarray:

but it should have been

def clip(
    x: ndarray,
    /,
    min: Optional[Union[int, float, ndarray]] = None,
    max: Optional[Union[int, float, ndarray]] = None,
    *,
    xp,
) -> ndarray:

The former works if you pass min and max as keywords but not if you pass them positionally (array-api-compat has a decorator that automatically injects the xp keyword argument into the final signature).

Additionally, some helpers to test optional positional arguments as both positional and keyword in the test itself would be useful. Right now we have specified_kwargs() but it doesn't allow passing the arguments as positional.

Dominant language
Python
Stars
74
Forks
54
Avg merge
4h 35m
Merged PRs (30d)
4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from data-apis/array-api-tests

All issues in data-apis/array-api-tests

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.