Ver código fonte

Replace NumericType with float

As described here: https://github.com/python/mypy/issues/6060

As a special case, int is considered a subtype of float, so the type
union is redundant.
Ryan C. Thompson 6 anos atrás
pai
commit
0576699104
1 arquivos alterados com 3 adições e 4 exclusões
  1. 3 4
      roll.py

+ 3 - 4
roll.py

@@ -608,8 +608,7 @@ op_dict: Dict[str, Callable] = {
     '^': operator.pow,
 }
 
-NumericType = Union[float,int]
-ExprType = Union[NumericType, str, ParseResults]
+ExprType = Union[float, str, ParseResults]
 
 def normalize_expr(expr: ExprType) -> ParseResults:
     if isinstance(expr, str):
@@ -624,7 +623,7 @@ def _eval_expr_internal(
         expr: ExprType,
         env: Dict[str, str] = {},
         print_rolls: bool = True,
-        recursed_vars: Set[str] = set()) -> NumericType:
+        recursed_vars: Set[str] = set()) -> float:
     if isinstance(expr, float) or isinstance(expr, int):
         # Numeric literal
         return expr
@@ -663,7 +662,7 @@ def _eval_expr_internal(
 
 def eval_expr(expr: ExprType,
               env: Dict[str,str] = {},
-              print_rolls: bool = True) -> NumericType:
+              print_rolls: bool = True) -> float:
     expr = normalize_expr(expr)
     return _eval_expr_internal(expr, env, print_rolls)