agateblue / agateblue/django-dynamic-preferences

FloatPreference should be able to be initialized from both floats and ints

オープン
#265 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
359
フォーク
86
PR マージ指標
30日以内にマージされた PR はありません

説明

Recently I met a problem with setting a `FloatPrefeerence` to an int value instead of its float equivalent (`1` instead of `1.0`), which sounds reasonable, but I got this error:

```
File "/app/.venv/lib/python3.10/site-packages/dynamic_preferences/models.py", line 53, in set_value
self.raw_value = self.preference.serializer.serialize(value)
File "/app/.venv/lib/python3.10/site-packages/dynamic_preferences/serializers.py", line 39, in serialize
return cls.to_db(value, **kwargs)
File "/app/.venv/lib/python3.10/site-packages/dynamic_preferences/serializers.py", line 54, in to_db
return text_type(cls.clean_to_db_value(value))
File "/app/.venv/lib/python3.10/site-packages/dynamic_preferences/serializers.py", line 163, in clean_to_db_value
raise cls.exception('FloatSerializer can only serialize Float instances')
```

`FloatSerializer` should INMHO accept ints as well, for more flexibility in user input

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。