Skip to content

Commit d26b28b

Browse files
committed
Improved compatibility with old versions of typing module by commenting out all usages of typing.Type in PEP484 annotations
Also added a few return type annotations.
1 parent b24f865 commit d26b28b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mini_lambda/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from copy import copy
22
from inspect import isclass
3-
from typing import Type, TypeVar, Union, Tuple, Callable
3+
from typing import TypeVar, Union, Tuple, Callable # do not import Type for compatibility with earlier python 3.5
44
from warnings import warn
55
import sys
66

@@ -509,7 +509,7 @@ def _(*expressions: _LambdaExpression) -> Union[_LambdaExpression.LambdaFunction
509509
""" Alias for '_' """
510510

511511

512-
def InputVar(symbol: str = None, typ: Type[T] = None) -> Union[T, _LambdaExpression]:
512+
def InputVar(symbol: str = None, typ: 'Type[T]' = None) -> Union[T, _LambdaExpression]:
513513
"""
514514
Creates a variable to use in validator expression. The optional `typ` argument may be used to get a variable with
515515
appropriate syntactic completion from your IDE, but is not used for anything else.
@@ -551,7 +551,7 @@ def Constant(value: T, name: str = None) -> Union[T, _LambdaExpression]:
551551
""" Alias for 'Constant' """
552552

553553

554-
def make_lambda_friendly_class(typ: Type, name: str = None):
554+
def make_lambda_friendly_class(typ: 'Type[T]', name: str = None) -> 'Union[Type[T], _LambdaExpression]':
555555
"""
556556
Utility method to transform a standard class into a class usable inside lambda expressions, as in
557557
DDataFrame = C(DataFrame), so as to be able to use it in expressions
@@ -563,7 +563,7 @@ def make_lambda_friendly_class(typ: Type, name: str = None):
563563
return Constant(typ, name=name)
564564

565565

566-
def make_lambda_friendly_method(method: Callable, name: str = None):
566+
def make_lambda_friendly_method(method: Callable, name: str = None) -> _LambdaExpression:
567567
"""
568568
Utility method to transform any method whatever their signature (positional and/or keyword arguments,
569569
variable-length included) into a method usable inside lambda expressions, even if some of the arguments are

0 commit comments

Comments
 (0)