Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Better signature tests for required arguments

Aperta
#281 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
testing

Direzione di ricerca

Inizia individuando i test delle signature e l’helper specified_kwargs() menzionati nell’issue, quindi esegui i test esistenti per comprenderne il comportamento attuale. Il lavoro è completato quando le signature con argomenti posizionali obbligatori aggiuntivi falliscono, mentre gli argomenti posizionali opzionali vengono testati sia posizionalmente sia tramite keyword.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
74
Fork
54
Merge medio
4h 35m
PR unite (30g)
4

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di data-apis/array-api-tests

Tutte le issue di data-apis/array-api-tests

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.