Docstring says t.Tuple is supported, but typing.Tuple raises AttributeError
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 88/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- documentation
Direzione di ricerca
Inizia dal docstring di Env in envier/env.py, righe 232-233, dove t.Tuple è elencato insieme a list e set. Leggi EnvVariable._cast (righe 78-87) e _check_type (righe 28-32) per confermare che l'alias nudo typing.Tuple non ha __args__. La correzione più semplice è cambiare il docstring in tuple; in alternativa, normalizza typing.Tuple/List/Set ai loro tipi di origine. Esegui i test delle collezioni esistenti e aggiungi un caso typing.Tuple se normalizzi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The Env docstring says t.Tuple is supported as a collection type, but declaring a variable with typing.Tuple raises AttributeError when the value is read. The builtin tuple works.
Environment: envier 0.6.1, Python 3.12
Reproduction
import json
import typing
from envier import Env
try:
class C(Env):
x = Env.var(typing.Tuple, "x")
print(json.dumps(C({"X": "a,b"}).x))
except Exception as e:
print(json.dumps(type(e).__name__))
Actual output
"AttributeError"
Expected output
["a", "b"]
From the Env class docstring:
There is also basic support for collections. An item of type
list,t.Tupleorsetwill be parsed using,as item separator.
Likely cause: EnvVariable._cast only handles _type in (list, tuple, set), so typing.Tuple falls through to _check_type, which reads _type.__args__; the bare typing.Tuple alias has no __args__:
https://github.com/DataDog/envier/blob/a8ee033fd2581be09c0d61eb6b8343f12c8f08e9/envier/env.py#L28-L32
https://github.com/DataDog/envier/blob/a8ee033fd2581be09c0d61eb6b8343f12c8f08e9/envier/env.py#L78-L87
Since the same sentence lists the builtins list and set and the tests use builtin tuple, the simplest fix may be to change t.Tuple to tuple in the docstring; alternatively typing.Tuple (and typing.List/typing.Set) could be normalized to their origin types.
Found while testing the library with an automated exploration tool; the reproduction above was re-run on 0.6.1 before filing.
- Lingua principale
- Python
- Stelle
- 9
- Fork
- 2
- Merge medio
- 7h 22m
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di DataDog/envier
-
Add `examples`Apertaenhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Add `version_added`Apertaenhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
Tutte le issue di DataDog/envier
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
OpenFreeEnergy/openfe#2371 ·
I maintainer di solito rispondono entro 2 giorni
-
HMDB's smiles file writes "None" for metabolites with an empty <smiles/> (file not currently used)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
NCATSTranslator/Babel#1269 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
404 on sample dataApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
bcgov/nr-hydrometric-rating-curve#443 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
twisted/incremental#214 ·