-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: yukinarit <[email protected]>
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# FAQ | ||
|
||
## pyserdeによって生成されたコードをどのように確認できますか? | ||
|
||
pyserdeはコマンドラインとして動作する `inspect` サブモジュールを提供しています。 | ||
``` | ||
python -m serde.inspect <PATH_TO_FILE> <CLASS> | ||
``` | ||
|
||
例:pyserdeプロジェクト内で以下を実行します。 | ||
|
||
``` | ||
cd pyserde | ||
poetry shell | ||
python -m serde.inspect examples/simple.py Foo | ||
``` | ||
|
||
出力 | ||
```python | ||
Loading simple.Foo from examples. | ||
|
||
================================================== | ||
Foo | ||
================================================== | ||
|
||
-------------------------------------------------- | ||
Functions generated by pyserde | ||
-------------------------------------------------- | ||
def to_iter(obj, reuse_instances=True, convert_sets=False): | ||
if reuse_instances is Ellipsis: | ||
reuse_instances = True | ||
if convert_sets is Ellipsis: | ||
convert_sets = False | ||
if not is_dataclass(obj): | ||
return copy.deepcopy(obj) | ||
|
||
Foo = serde_scope.types["Foo"] | ||
res = [] | ||
res.append(obj.i) | ||
res.append(obj.s) | ||
res.append(obj.f) | ||
res.append(obj.b) | ||
return tuple(res) | ||
... | ||
``` |