Improve "not found" error messages in `<sequence>.<method>()` failures
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
The docstring of list.remove() says value parameter as shown below:
print(help(list.remove))
# remove(self, value, /) unbound builtins.list method
# Remove first occurrence of value.
#
# Raises ValueError if the value is not present.
But the error message says x instead of value as shown below and I don't think list.remove(x): is necessary:
v = ['a', 'b', 'c']
v.remove('B')
# ValueError: list.remove(x): x not in list
So, the error message should just say as shown below:
ValueError: value not in list
In addition, the docstring of bytearray.remove() says valueparameter as shown below:
print(help(bytearray.remove))
# remove(self, value, /) unbound builtins.bytearray method
# Remove the first occurrence of a value in the bytearray.
#
# value
# The value to remove.
And, the error message reasonably says value as shown below but I don't think found is necessary:
v = bytearray(b'abc')
v.remove(ord('B'))
# ValueError: value not found in bytearray
So, the error message should just say as shown below:
ValueError: value not in bytearray
Linked PRs
- gh-137509
- gh-139696
Beitragsleitfaden
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
Beginne damit, die Implementierungen und Tests für list.remove() und bytearray.remove() zu finden, und verwende die gemeldeten Beispiele als Verhaltensreferenz. Prüfe die verknüpften PRs gh-137509 und gh-139696, bevor du beginnst; abgeschlossen ist die Aufgabe, wenn die beiden Fehlermeldungen dem gewünschten Wortlaut entsprechen und die relevanten Tests erfolgreich sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 25/100