Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ repos:
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- "--py38-plus"
2 changes: 1 addition & 1 deletion src/rok4/Pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def list_generator(self) -> Iterator[Tuple[Tuple[SlabType, str, int, int], Dict]
roots = {}
s3_cluster = self.storage_s3_cluster

with open(list_file, "r") as listin:
with open(list_file) as listin:
# Lecture des racines
for line in listin:
line = line.rstrip()
Expand Down
12 changes: 4 additions & 8 deletions src/rok4/Storage.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Même s'il n'était pas forcément prévu de faire des noms d'objets avec des accents, quel est l'intérêt de ne pas forcer l'encodage UTF-8 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parce-que c'est l'encodage par défaut du langage donc ça ne présente pas beaucoup d'intérêt de le spécifier donc autant ne pas le mettre ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour le coup j'ai du le rajouter à d'autres endroits (pour l'écriture de descripteur) justement parce que mes accents ne passaient pas sinon. Le côté explicite me rassure j'avoue 😇

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiens, c'est étonnant. Je suis preneur d'un échange avec un jeu de données exemple sur ce cas-là. En général, s'il s'agit d'écrire dans un fichier, c'est au niveau du flux i/o qu'on spécifie l'encodage.

Typiquement :

from pathlib import Path

with Path("fichier.json").open(mode="w", encoding="utf-8") as f:
    f.write("ma chaïne de caractères @!")

Mais je réponds sans avoir de setup sous les yeux ni même l'endroit du code où cela a un impact.

Ce serait dommage de se priver de ce git hook qui fait un travail automatique à haute valeur ajoutée !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est pyupgrade qui vire l'encodage ou le mode ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyupgrade

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

À surveiller...

Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,9 @@ def link(target_path: str, link_path: str, hard: bool = False) -> None:

try:
target_s3_client["client"].put_object(
Body=f"{__OBJECT_SYMLINK_SIGNATURE}{target_bucket}/{target_base_name}".encode(
"utf-8"
),
Bucket=link_bucket,
Key=link_base_name,
Body = f"{__OBJECT_SYMLINK_SIGNATURE}{target_bucket}/{target_base_name}".encode(),
Bucket = link_bucket,
Key = link_base_name
)
except Exception as e:
raise StorageError("S3", e)
Expand All @@ -854,9 +852,7 @@ def link(target_path: str, link_path: str, hard: bool = False) -> None:
ioctx = __get_ceph_ioctx(link_tray)

try:
ioctx.write_full(
link_base_name, f"{__OBJECT_SYMLINK_SIGNATURE}{target_path}".encode("utf-8")
)
ioctx.write_full(link_base_name, f"{__OBJECT_SYMLINK_SIGNATURE}{target_path}".encode())
except Exception as e:
raise StorageError("CEPH", e)

Expand Down