b2sdk: create_file prioritization should accept an enum, not a string

Offen
#602 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

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
22/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
python
Bereich
api

Rechercherichtung

Start with Bucket.create_file and Bucket.create_file_stream in the b2sdk bucket module, and the .. TODO:: note in doc/source/advanced.rst that describes the current string values local, remote and local_verification. The design choices are open: the enum's member names, how strings stay accepted for backwards compatibility, and what an unknown value should raise. Settle those with a maintainer before coding. Done means both methods take the enum, the string values still work, and the typo case in the reproduction fails at the call site.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Description

Bucket.create_file and Bucket.create_file_stream accept source prioritization as a string, with the supported values being local, remote and local_verification. An enum would make the valid values discoverable through the type system and turn a typo into an immediate error rather than a silently different plan.

This was recorded as a .. TODO:: directive in doc/source/advanced.rst, where it was invisible in published builds and carried no owner or acceptance criteria. It is tracked here instead, as part of #601.

Note that this is an API design change rather than a documentation change, so it is filed separately from the documentation work in #601.

Steps to reproduce

bucket.create_file(input_sources, remote_name, file_info, prioritize='local')
bucket.create_file(input_sources, remote_name, file_info, prioritize='locol')  # typo, not rejected at the call site

Expected behavior

Prioritization should be expressed as an enum, with the string values continuing to be accepted for backwards compatibility within the current interface version.

Actual behavior

Only strings are accepted, and an unrecognised value is not caught at the call site.

Environment

  • Python version: Any supported version
  • b2sdk version: master at f3ab7b71
  • OS: Any
Vorherrschende Sprache
Python
Sterne
214
Forks
68
Ø Merge
51 Min.
Gemergte PRs (30 T.)
6

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Backblaze/b2-sdk-python

Alle Issues in Backblaze/b2-sdk-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.