Adding some utility methods to Maybe/Result
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne mit der Überprüfung der Implementierungen der Maybe- und Result-Container sowie der Diskussion im zugehörigen Issue #1091. Bestimme, welche der vorgeschlagenen Methoden setdefault, zip, filter, and_, und or_ im Umfang enthalten sind, und bestätige ihr Verhalten für erfolgreiche und leere Container mit Tests; abgeschlossen bedeutet, dass die vereinbarten Hilfsfunktionen und Beispiele konsistent implementiert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Have you considered adding some handy utility functions to Maybe and Result?
In using returns I'm missing many helpful methods you can find in Rust, for example.
Adding a few of these could increase the usability of the containers of returns.
Related: #1091
Here they are, in my subjective order of usefulness:
Setdefault
Set a value if one is not yet present.
The name setdefault would be consistent with the python dict method.
(Although it might be good to choose another name to make clear that
the method doesn't mutate.)
>>> Some(6).setdefault(7)
Some(6)
>>> Nothing.setdefault(3)
Some(3)
Zip
Combine the values from two containers into a tuple, if both are successful.
>>> Some(8).zip(Some(2))
Some((8, 2))
>>> Some(7).zip(Nothing)
Nothing
>>> Nothing.zip(Some(3))
Nothing
>>> Nothing.zip(Nothing)
Nothing
Filter
Keep a value based on a predicate
>>> Some("9").filter(str.isdigit)
Some("9")
>>> Some("foo3").filter(str.isdigit)
Nothing
>>> Nothing.filter(str.isdigit)
Nothing
And
AND logic operation
>>> Some(5).and_(Some(9))
Some(9)
>>> Some(9).and_(Nothing)
Nothing
>>> Nothing.and_(Some(8))
Nothing
Or
OR logic operation
>>> Some(5).or_(Some(9))
Some(5)
>>> Some(9).or_(Nothing)
Some(9)
>>> Nothing.or_(Some(8))
Some(8)
>>> Nothing.or_(Nothing)
Nothing
- Vorherrschende Sprache
- Python
- Sterne
- 4.4k
- Forks
- 156
- Ø Merge
- 3 Std. 44 Min.
- Gemergte PRs (30 T.)
- 22
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus dry-python/returns
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
dry-python/returns#2394 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
dry-python/returns#2365 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
dry-python/returns#2355 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
dry-python/returns#2295 · 4 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
dry-python/returns#2253 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in dry-python/returns
Ähnliche Issues
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 87/100
adri0/scadustats#128 ·
Maintainer antworten meist innerhalb von 1 Tag
-
`TIMESTAMP`, `TIMESTAMP_NTZ`, `TINYINT` and the other `TypeDecorator`s don't declare `python_type`Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
RPBCOffenawaiting policy acceptance precheck-passed
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
Bioconductor/BiocContributions#240 · 1 Kommentar ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
documentation good first issue launch
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
FlologixAI/etchwork#4 ·