This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new fed97441e fix(python): fix wrong calling orders in visit_other (#3542)
fed97441e is described below
commit fed97441e601e32a2f3c07f814d21026786fdea6
Author: Peiyang He <[email protected]>
AuthorDate: Tue Apr 7 13:54:19 2026 +0800
fix(python): fix wrong calling orders in visit_other (#3542)
## Why?
Fix failed test case `test_type_id`.
## What does this PR do?
- Change the calling orders in the `visit_other` function so that the
type id of `datetime.date` can be correctly resolved.
- Cover testcases under `python/pyfory/format/tests` in CI in case of
any regression bugs.
## Related issues
Fixes https://github.com/apache/fory/issues/3540.
## AI Contribution Checklist
No.
## Does this PR introduce any user-facing change?
No.
## Benchmark
No.
---
ci/tasks/python.py | 1 +
python/pyfory/format/infer.py | 12 ++++++------
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/ci/tasks/python.py b/ci/tasks/python.py
index ea53e9433..f9684d43f 100644
--- a/ci/tasks/python.py
+++ b/ci/tasks/python.py
@@ -53,6 +53,7 @@ def run():
# Run tests with default settings
common.exec_cmd("pytest -v -s --durations=60 pyfory/tests")
+ common.exec_cmd("pytest -v -s --durations=60 pyfory/format/tests")
logging.info("Executing fory python tests succeeds")
diff --git a/python/pyfory/format/infer.py b/python/pyfory/format/infer.py
index 09ed38332..e28b81c2a 100644
--- a/python/pyfory/format/infer.py
+++ b/python/pyfory/format/infer.py
@@ -192,14 +192,14 @@ class ForyTypeVisitor(TypeVisitor):
return field(field_name, struct(fields))
def visit_other(self, field_name, type_, types_path=None):
+ if type_ in _supported_types_mapping:
+ fory_type_func = _supported_types_mapping.get(type_)
+ return field(field_name, fory_type_func())
if isinstance(type_, type) and type_.__module__ != "builtins":
return self.visit_customized(field_name, type_,
types_path=types_path)
- if type_ not in _supported_types_mapping:
- raise TypeError(
- f"Type {type_} not supported, currently only compositions of
{_supported_types_str} are supported. types_path is {types_path}"
- )
- fory_type_func = _supported_types_mapping.get(type_)
- return field(field_name, fory_type_func())
+ raise TypeError(
+ f"Type {type_} not supported, currently only compositions of
{_supported_types_str} are supported. types_path is {types_path}"
+ )
def infer_data_type(clz) -> Optional[DataType]:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]