Fix ConversionPoint.fn_args ignorance of type annot override
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "breakshaft"
|
name = "breakshaft"
|
||||||
version = "0.1.1"
|
version = "0.1.1.post1"
|
||||||
description = "Library for in-time codegen for type conversion"
|
description = "Library for in-time codegen for type conversion"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "nikto_b", email = "niktob560@yandex.ru" }
|
{ name = "nikto_b", email = "niktob560@yandex.ru" }
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from typing import Callable, Optional, get_type_hints, get_origin, Generator, ge
|
|||||||
|
|
||||||
from .util import extract_func_argtypes, extract_func_argtypes_seq, is_sync_context_manager_factory, \
|
from .util import extract_func_argtypes, extract_func_argtypes_seq, is_sync_context_manager_factory, \
|
||||||
is_async_context_manager_factory, \
|
is_async_context_manager_factory, \
|
||||||
all_combinations, is_context_manager_factory, extract_func_arg_defaults, extract_func_args
|
all_combinations, is_context_manager_factory, extract_func_arg_defaults, extract_func_args, extract_func_argnames
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
@@ -35,7 +35,8 @@ class ConversionPoint:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def fn_args(self) -> list[tuple[str, type]]:
|
def fn_args(self) -> list[tuple[str, type]]:
|
||||||
return extract_func_args(self.fn)
|
funcnames = extract_func_argnames(self.fn)
|
||||||
|
return list(zip(funcnames, self.requires + self.opt_args))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_ctx_manager(self) -> bool:
|
def is_ctx_manager(self) -> bool:
|
||||||
|
|||||||
@@ -3,6 +3,15 @@ from itertools import product
|
|||||||
from typing import Callable, get_type_hints, TypeVar, Any, Optional
|
from typing import Callable, get_type_hints, TypeVar, Any, Optional
|
||||||
|
|
||||||
|
|
||||||
|
def extract_func_argnames(func: Callable) -> list[str]:
|
||||||
|
sig = inspect.signature(func)
|
||||||
|
params = sig.parameters
|
||||||
|
|
||||||
|
args_info = []
|
||||||
|
for name, _ in params.items():
|
||||||
|
args_info.append(name)
|
||||||
|
return args_info
|
||||||
|
|
||||||
def extract_return_type(func: Callable) -> Optional[type]:
|
def extract_return_type(func: Callable) -> Optional[type]:
|
||||||
hints = get_type_hints(func)
|
hints = get_type_hints(func)
|
||||||
return hints.get('return')
|
return hints.get('return')
|
||||||
|
|||||||
Reference in New Issue
Block a user