"TypeError: Argument of type 'Bucket' cannot be assigned to parameter of type 'Bucket' in b2sdk.v2"
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 25/100
Piste de recherche
Start with the v2 re-exports in the b2sdk/v2 package and the Bucket class it exposes, then compare them with the implementation under b2sdk/_internal. Check whether B2Api.get_bucket_by_name() returns the same class the public Bucket name points to, and reproduce the ls(latest_only=True) call. Done means the returned object passes the b2.Bucket annotation and ls() runs, or the import path that causes the mismatch is documented. Read the four comments first, since the maintainers may already have explained the cause.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Issue Description
When attempting to use the ls() method on a Bucket object obtained from b2sdk.v2.B2Api.get_bucket_by_name(), I encountered a TypeError stating that the Bucket argument type is incompatible with the expected 'Bucket' parameter type. It appears that get_bucket_by_name() may be returning an internal SDK type not intended for direct use, despite being accessed through the public API.
Steps to Reproduce
- Setup a basic environment with b2sdk.v2 configured with valid Backblaze B2 credentials.
- Fetch a
BucketusingB2Api.get_bucket_by_name(). - Attempt to list directories or files using the
Bucket.ls()method. - Observe the TypeError related to incompatible type assignment.
Expected Behavior
The Bucket object returned from get_bucket_by_name() should be fully compatible with other methods expecting a Bucket type as defined in the b2sdk.v2 public API.
Actual Behavior
A TypeError is raised suggesting type incompatibility, indicating possible exposure of internal types in what should be a public API method.
Environment
- Python version: 3.12
- b2sdk version: 2.1
Additional Context
This issue seems to stem from recent changes in the SDK where non-api packages were moved to b2sdk._internal as noted in the changelog for version 2.0.0. It would be helpful to confirm whether get_bucket_by_name() should return a type from b2sdk.v2 or if there's a recommended workaround for this type mismatch.
import b2sdk.v2 as b2
def get_bucket():
info = b2.InMemoryAccountInfo()
b2_api = b2.B2Api(info)
b2_api.authorize_account("production", settings.BACKBLAZE_KEY_ID, settings.BACKBLAZE_APPLICATION_KEY)
return b2_api.get_bucket_by_name(settings.BACKBLAZE_BUCKET_NAME)
def list_directories(bucket: b2.Bucket):
try:
for file_version, folder_name in bucket.ls(latest_only=True):
print(folder_name)
except TypeError as e:
print(f"TypeError: {str(e)}")
# Example
bucket = get_bucket()
list_directories(bucket)
- Langage dominant
- Python
- Étoiles
- 214
- Forks
- 68
- Merge moyen
- 51 min
- PR mergées (30 j)
- 6
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de Backblaze/b2-sdk-python
-
Download and copy sync actions print remote file names without escape_control_charsPeut-être pris @dreyfus92 l’a pris il y a 15 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Backblaze/b2-sdk-python#631 ·
Les mainteneurs répondent en général sous 1 jour
-
SqliteAccountInfo profile name validation uses "re.match", so only the first character is checkedPeut-être pris @nazarli-shabnam l’a pris il y a 9 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Backblaze/b2-sdk-python#629 ·
Les mainteneurs répondent en général sous 1 jour
-
Adopt the AI-native SDLC and repository policiesPeut-être pris @goanpeca l’a pris il y a 18 jours. Ouverteenhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
Backblaze/b2-sdk-python#634 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 50/100
Backblaze/b2-sdk-python#630 ·
Les mainteneurs répondent en général sous 1 jour
-
ci: cli-compat fails — 4 sse/sync integration tests broken in B2_Command_Line_Tool (all environments)Peut-être à nouveau libre @ffumero2003 l’a pris il y a 37 jours, et aucune pull request n’est ouverte. Ouvertebug testing
Backblaze/b2-sdk-python#627 · 2 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de Backblaze/b2-sdk-python
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
btclib-org/btclib-node#2505 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
open-webui/open-webui#34462 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
gorakhargosh/watchdog#1462 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
openwisp/openwisp-monitoring#889 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
IETF-Hackathon/pqc-certificates#351 ·
Les mainteneurs répondent en général sous 2 jours