Remove core.python.arguments.PythonFunctionArgumentDefault; use strings instead

This commit is contained in:
2026-04-12 18:54:51 +02:00
parent 076e04a67a
commit 73730520c1
2 changed files with 3 additions and 77 deletions
+3 -22
View File
@@ -23,7 +23,6 @@ import types
__all__ = [
'PythonArgumentKind',
'PythonFunctionArgumentDefault',
'PythonFunctionArgument',
'PythonASTArgumentsListParser'
]
@@ -35,24 +34,6 @@ class PythonArgumentKind(Enum):
VARARG = 3
KWARGS = 4
class PythonFunctionArgumentDefault:
'''
Represents the default value of a Python function argument.
:param value: The value
:type value: ast.expr
'''
def __init__(self, value: ast.expr) -> None:
assert_that_is_instance(value, ast.expr)
self.value = value
def __eq__(self, value: PythonFunctionArgumentDefault) -> bool:
if not isinstance(value, PythonFunctionArgumentDefault):
return False
return ast.dump(value.value, include_attributes = False) == ast.dump(self.value, include_attributes = False)
class PythonFunctionArgument:
'''
Represents an argument of a Python function.
@@ -62,15 +43,15 @@ class PythonFunctionArgument:
:param kind: The kind of the argument.
:type kind: ArgumentKind
:param default: The default value of the argument.
:type default: Union[PythonFunctionArgumentDefault, None]
:type default: Union[str, None]
:param annotation: The type annotation of the argument.
:type annotation: Union[str, None]
'''
def __init__(self, name: str, kind: PythonArgumentKind, default: Union[PythonFunctionArgumentDefault, None], annotation: Union[str, None]) -> None:
def __init__(self, name: str, kind: PythonArgumentKind, default: Union[str, None], annotation: Union[str, None]) -> None:
assert_that_is_instance(name, str)
assert_that_is_instance(kind, PythonArgumentKind)
assert_that_is_instance(default, (PythonFunctionArgumentDefault, types.NoneType))
assert_that_is_instance(default, (str, types.NoneType))
assert_that_is_instance(annotation, (str, types.NoneType))
# check whether name is a valid identifier