fix: Fixed the plugin not being loadable in Python versions earlier than 3.10
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from typing import Any, Mapping
|
||||
|
||||
from .vec import Vec2, VEC2_ZERO, Vec3, VEC3_ZERO, Vec4, VEC4_ZERO
|
||||
from .number import number
|
||||
from .vec import VEC2_ZERO, VEC3_ZERO, VEC4_ZERO
|
||||
from .types import Number, Vec2, Vec3, Vec4
|
||||
|
||||
|
||||
class BoolToInt:
|
||||
@@ -65,7 +65,7 @@ class IntToNumber:
|
||||
FUNCTION = "op"
|
||||
CATEGORY = "math/conversion"
|
||||
|
||||
def op(self, a: int) -> tuple[number]:
|
||||
def op(self, a: int) -> tuple[Number]:
|
||||
return (a,)
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class NumberToInt:
|
||||
FUNCTION = "op"
|
||||
CATEGORY = "math/conversion"
|
||||
|
||||
def op(self, a: number) -> tuple[int]:
|
||||
def op(self, a: Number) -> tuple[int]:
|
||||
return (int(a),)
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ class FloatToNumber:
|
||||
FUNCTION = "op"
|
||||
CATEGORY = "math/conversion"
|
||||
|
||||
def op(self, a: float) -> tuple[number]:
|
||||
def op(self, a: float) -> tuple[Number]:
|
||||
return (a,)
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class NumberToFloat:
|
||||
FUNCTION = "op"
|
||||
CATEGORY = "math/conversion"
|
||||
|
||||
def op(self, a: number) -> tuple[float]:
|
||||
def op(self, a: Number) -> tuple[float]:
|
||||
return (float(a),)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Callable, Mapping, TypeAlias
|
||||
from typing import Any, Callable, Mapping
|
||||
|
||||
from .float import (
|
||||
FLOAT_UNARY_OPERATIONS,
|
||||
@@ -7,11 +7,10 @@ from .float import (
|
||||
FLOAT_BINARY_OPERATIONS,
|
||||
FLOAT_BINARY_CONDITIONS,
|
||||
)
|
||||
from .types import Number
|
||||
|
||||
DEFAULT_NUMBER = ("NUMBER", {"default": 0.0})
|
||||
|
||||
number: TypeAlias = int | float
|
||||
|
||||
|
||||
class NumberUnaryOperation:
|
||||
@classmethod
|
||||
@@ -27,7 +26,7 @@ class NumberUnaryOperation:
|
||||
FUNCTION = "op"
|
||||
CATEGORY = "math/number"
|
||||
|
||||
def op(self, op: str, a: number) -> tuple[float]:
|
||||
def op(self, op: str, a: Number) -> tuple[float]:
|
||||
return (FLOAT_UNARY_OPERATIONS[op](float(a)),)
|
||||
|
||||
|
||||
@@ -43,9 +42,9 @@ class NumberUnaryCondition:
|
||||
|
||||
RETURN_TYPES = ("BOOL",)
|
||||
FUNCTION = "op"
|
||||
CATEGORY = "math/number"
|
||||
CATEGORY = "math/Number"
|
||||
|
||||
def op(self, op: str, a: number) -> tuple[bool]:
|
||||
def op(self, op: str, a: Number) -> tuple[bool]:
|
||||
return (FLOAT_UNARY_CONDITIONS[op](float(a)),)
|
||||
|
||||
|
||||
@@ -64,7 +63,7 @@ class NumberBinaryOperation:
|
||||
FUNCTION = "op"
|
||||
CATEGORY = "math/number"
|
||||
|
||||
def op(self, op: str, a: number, b: number) -> tuple[float]:
|
||||
def op(self, op: str, a: Number, b: Number) -> tuple[float]:
|
||||
return (FLOAT_BINARY_OPERATIONS[op](float(a), float(b)),)
|
||||
|
||||
|
||||
@@ -83,7 +82,7 @@ class NumberBinaryCondition:
|
||||
FUNCTION = "op"
|
||||
CATEGORY = "math/float"
|
||||
|
||||
def op(self, op: str, a: number, b: number) -> tuple[bool]:
|
||||
def op(self, op: str, a: Number, b: Number) -> tuple[bool]:
|
||||
return (FLOAT_BINARY_CONDITIONS[op](float(a), float(b)),)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import sys
|
||||
|
||||
if sys.version_info[1] < 10:
|
||||
from typing import Tuple, Union
|
||||
|
||||
Number = Union[int, float]
|
||||
Vec2 = Tuple[float, float]
|
||||
Vec3 = Tuple[float, float, float]
|
||||
Vec4 = Tuple[float, float, float, float]
|
||||
else:
|
||||
from typing import TypeAlias
|
||||
|
||||
Number: TypeAlias = int | float
|
||||
Vec2: TypeAlias = tuple[float, float]
|
||||
Vec3: TypeAlias = tuple[float, float, float]
|
||||
Vec4: TypeAlias = tuple[float, float, float, float]
|
||||
@@ -1,16 +1,15 @@
|
||||
import numpy
|
||||
|
||||
from typing import Any, Callable, Mapping, TypeAlias
|
||||
from typing import Any, Callable, Mapping
|
||||
|
||||
from .types import Vec2, Vec3, Vec4
|
||||
|
||||
Vec2: TypeAlias = tuple[float, float]
|
||||
VEC2_ZERO = (0.0, 0.0)
|
||||
DEFAULT_VEC2 = ("VEC2", {"default": VEC2_ZERO})
|
||||
|
||||
Vec3: TypeAlias = tuple[float, float, float]
|
||||
VEC3_ZERO = (0.0, 0.0, 0.0)
|
||||
DEFAULT_VEC3 = ("VEC3", {"default": VEC3_ZERO})
|
||||
|
||||
Vec4: TypeAlias = tuple[float, float, float, float]
|
||||
VEC4_ZERO = (0.0, 0.0, 0.0, 0.0)
|
||||
DEFAULT_VEC4 = ("VEC4", {"default": VEC4_ZERO})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user