Private identity objects are not singletons.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 1.8k
- Forks
- 302
- Ø Merge
- 23 Std.
- Gemergte PRs (30 T.)
- 8
Beschreibung
In the subsection describing singletons in unions, widely used object() example is described as a singleton, but it isn't one. It should be clearly stated that the problem for typing system is that this instance is not a singleton, that's why Enum is needed.
_empty = object() works with is check, because identity of _empty doesn't leak outside of module. There is nothing singleton about that. Typing spec can allow requiring _empty to be one, to allow use with is, but that should be clear it's the case.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit dem Unterabschnitt „Support for singleton types in unions“ in der verlinkten Typing-Spezifikation. Stellen Sie klar, dass eine object()-Instanz nicht inhärent ein Singleton ist, erklären Sie, warum Enum für die Singleton-Typisierung benötigt wird, und bewahren Sie die Unterscheidung zu einem privaten object, dessen Identität nur innerhalb seines Moduls geprüft wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 55/100