Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Support python3.11/12 #1064

Merged
merged 17 commits into from
Nov 21, 2023
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

Prev Previous commit
fix python arrow type infer
chaokunyang committed Nov 21, 2023
commit 21b1d626c0d7b063fa4046b36976c8607442392e
15 changes: 12 additions & 3 deletions python/pyfury/type.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import dataclasses
import enum
import importlib
import inspect

import typing
from typing import TypeVar
@@ -313,10 +314,18 @@ def infer_field(field_name, type_, visitor: TypeVisitor, types_path=None):
f"Collection types should be {list, dict} instead of {type_}"
)
else:
if hasattr(origin, "__annotations__"):
return visitor.visit_customized(field_name, type_, types_path=types_path)
else:
if is_function(origin) or not hasattr(origin, "__annotations__"):
return visitor.visit_other(field_name, type_, types_path=types_path)
else:
return visitor.visit_customized(field_name, type_, types_path=types_path)


def is_function(func):
return inspect.isfunction(func) or is_cython_function(func)


def is_cython_function(func):
return getattr(func, "func_name", None) is not None


def compute_string_hash(string):