File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33"""
44
55import collections
6+ import inspect
67import typing
78from pathlib import Path
89from typing import Any , Callable , NamedTuple
@@ -36,12 +37,23 @@ class Converter(NamedTuple):
3637def _convert (obj : Any , converters : typing .List [Converter ], ** kwargs : dict ) -> Any :
3738 suitable_converters = filter (lambda c : c .predicate (obj ), converters )
3839 prioritized = max (suitable_converters , key = lambda c : c .priority )
39- if kwargs :
40+ # check if select converter supports kwargs
41+ if _check_func_uses_kwargs (prioritized .converter ):
4042 return prioritized .converter (obj , ** kwargs )
4143 else :
4244 return prioritized .converter (obj )
4345
4446
47+ def _check_func_uses_kwargs (func ):
48+ if isjava (func ):
49+ return False
50+ else :
51+ return any (
52+ p .kind == inspect .Parameter .VAR_KEYWORD
53+ for p in inspect .signature (func ).parameters .values ()
54+ )
55+
56+
4557# -- Python to Java --
4658
4759# Adapted from code posted by vslotman on GitHub:
You can’t perform that action at this time.
0 commit comments