build: minor changes

This commit is contained in:
Anand Balakrishnan 2023-09-06 13:30:59 -07:00
parent 980a08227f
commit a52f6a756c
No known key found for this signature in database
5 changed files with 64 additions and 51 deletions

View file

@ -72,7 +72,9 @@ def ruff(session: nox.Session):
def mypy(session: nox.Session): def mypy(session: nox.Session):
session.conda_install("mypy", "typing-extensions", "pytest", "hypothesis") session.conda_install("mypy", "typing-extensions", "pytest", "hypothesis")
with session.chdir(CURRENT_DIR / "pyargus"): with session.chdir(CURRENT_DIR / "pyargus"):
session.install("-e", ".")
session.run("mypy", ".") session.run("mypy", ".")
session.run("stubtest", "argus")
@nox.session @nox.session
@ -80,8 +82,14 @@ def tests(session: nox.Session):
session.conda_install("pytest", "hypothesis") session.conda_install("pytest", "hypothesis")
session.env.update(ENV) session.env.update(ENV)
session.install("-e", "./pyargus") session.install("-e", "./pyargus")
session.run("cargo", "test", external=True) try:
session.run("pytest", "pyargus") session.run("cargo", "test", external=True)
except Exception:
...
try:
session.run("pytest", "pyargus")
except Exception:
...
@nox.session @nox.session

View file

@ -13,5 +13,5 @@ argus-semantics = { version = "0.1.0", path = "../argus-semantics" }
derive_more = "0.99.17" derive_more = "0.99.17"
log = "0.4.20" log = "0.4.20"
paste = "1.0.14" paste = "1.0.14"
pyo3 = { version = "0.19.2", features = ["extension-module"] } pyo3 = "0.19.2"
pyo3-log = "0.8.3" pyo3-log = "0.8.3"

View file

@ -3,81 +3,81 @@ from typing import ClassVar, Protocol, TypeVar, final
from typing_extensions import Self from typing_extensions import Self
class NumExpr(Protocol): class NumExpr(Protocol):
def __ge__(self, other) -> NumExpr: ... def __ge__(self, other: Self) -> NumExpr: ...
def __gt__(self, other) -> NumExpr: ... def __gt__(self, other: Self) -> NumExpr: ...
def __le__(self, other) -> NumExpr: ... def __le__(self, other: Self) -> NumExpr: ...
def __lt__(self, other) -> NumExpr: ... def __lt__(self, other: Self) -> NumExpr: ...
def __mul__(self, other) -> NumExpr: ... def __mul__(self, other: Self) -> NumExpr: ...
def __eq__(self, other) -> NumExpr: ... # type: ignore[override] def __eq__(self, other: Self) -> NumExpr: ... # type: ignore[override]
def __ne__(self, other) -> NumExpr: ... # type: ignore[override] def __ne__(self, other: Self) -> NumExpr: ... # type: ignore[override]
def __neg__(self) -> NumExpr: ... def __neg__(self) -> NumExpr: ...
def __add__(self, other) -> NumExpr: ... def __add__(self, other: Self) -> NumExpr: ...
def __radd__(self, other) -> NumExpr: ... def __radd__(self, other: Self) -> NumExpr: ...
def __rmul__(self, other) -> NumExpr: ... def __rmul__(self, other: Self) -> NumExpr: ...
def __sub__(self, other) -> NumExpr: ... def __sub__(self, other: Self) -> NumExpr: ...
def __rsub__(self, other) -> NumExpr: ... def __rsub__(self, other: Self) -> NumExpr: ...
def __truediv__(self, other) -> NumExpr: ... def __truediv__(self, other: Self) -> NumExpr: ...
def __rtruediv__(self, other) -> NumExpr: ... def __rtruediv__(self, other: Self) -> NumExpr: ...
def __abs__(self) -> NumExpr: ... def __abs__(self) -> NumExpr: ...
@final @final
class ConstInt(NumExpr): class ConstInt(NumExpr):
def __init__(self, value: int): ... def __init__(self, value: int) -> None: ...
@final @final
class ConstUInt(NumExpr): class ConstUInt(NumExpr):
def __init__(self, value: int): ... def __init__(self, value: int) -> None: ...
@final @final
class ConstFloat(NumExpr): class ConstFloat(NumExpr):
def __init__(self, value: float): ... def __init__(self, value: float) -> None: ...
@final @final
class VarInt(NumExpr): class VarInt(NumExpr):
def __init__(self, name: str): ... def __init__(self, name: str) -> None: ...
@final @final
class VarUInt(NumExpr): class VarUInt(NumExpr):
def __init__(self, name: str): ... def __init__(self, name: str) -> None: ...
@final @final
class VarFloat(NumExpr): class VarFloat(NumExpr):
def __init__(self, name: str): ... def __init__(self, name: str) -> None: ...
@final @final
class Negate(NumExpr): class Negate(NumExpr):
def __init__(self, arg: NumExpr): ... def __init__(self, arg: NumExpr) -> None: ...
@final @final
class Add(NumExpr): class Add(NumExpr):
def __init__(self, args: list[NumExpr]): ... def __init__(self, args: list[NumExpr]) -> None: ...
@final @final
class Mul(NumExpr): class Mul(NumExpr):
def __init__(self, args: list[NumExpr]): ... def __init__(self, args: list[NumExpr]) -> None: ...
@final @final
class Div(NumExpr): class Div(NumExpr):
def __init__(self, dividend: NumExpr, divisor: NumExpr): ... def __init__(self, dividend: NumExpr, divisor: NumExpr) -> None: ...
@final @final
class Abs(NumExpr): class Abs(NumExpr):
def __init__(self, arg: NumExpr): ... def __init__(self, arg: NumExpr) -> None: ...
class BoolExpr(Protocol): class BoolExpr(Protocol):
def __and__(self, other) -> BoolExpr: ... def __and__(self, other: Self) -> BoolExpr: ...
def __invert__(self) -> BoolExpr: ... def __invert__(self) -> BoolExpr: ...
def __or__(self, other) -> BoolExpr: ... def __or__(self, other: Self) -> BoolExpr: ...
def __rand__(self, other) -> BoolExpr: ... def __rand__(self, other: Self) -> BoolExpr: ...
def __ror__(self, other) -> BoolExpr: ... def __ror__(self, other: Self) -> BoolExpr: ...
@final @final
class ConstBool(BoolExpr): class ConstBool(BoolExpr):
def __init__(self, value: bool): ... def __init__(self, value: bool) -> None: ...
@final @final
class VarBool(BoolExpr): class VarBool(BoolExpr):
def __init__(self, name: str): ... def __init__(self, name: str) -> None: ...
@final @final
class Cmp(BoolExpr): class Cmp(BoolExpr):
@ -96,31 +96,31 @@ class Cmp(BoolExpr):
@final @final
class Not(BoolExpr): class Not(BoolExpr):
def __init__(self, arg: BoolExpr): ... def __init__(self, arg: BoolExpr) -> None: ...
@final @final
class And(BoolExpr): class And(BoolExpr):
def __init__(self, args: list[BoolExpr]): ... def __init__(self, args: list[BoolExpr]) -> None: ...
@final @final
class Or(BoolExpr): class Or(BoolExpr):
def __init__(self, args: list[BoolExpr]): ... def __init__(self, args: list[BoolExpr]) -> None: ...
@final @final
class Next(BoolExpr): class Next(BoolExpr):
def __init__(self, arg: BoolExpr): ... def __init__(self, arg: BoolExpr) -> None: ...
@final @final
class Always(BoolExpr): class Always(BoolExpr):
def __init__(self, arg: BoolExpr): ... def __init__(self, arg: BoolExpr) -> None: ...
@final @final
class Eventually(BoolExpr): class Eventually(BoolExpr):
def __init__(self, arg: BoolExpr): ... def __init__(self, arg: BoolExpr) -> None: ...
@final @final
class Until(BoolExpr): class Until(BoolExpr):
def __init__(self, lhs: BoolExpr, rhs: BoolExpr): ... def __init__(self, lhs: BoolExpr, rhs: BoolExpr) -> None: ...
@final @final
class DType: class DType:
@ -131,7 +131,7 @@ class DType:
@classmethod @classmethod
def convert(cls, dtype: type[bool | int | float] | Self) -> Self: ... # noqa: Y041 def convert(cls, dtype: type[bool | int | float] | Self) -> Self: ... # noqa: Y041
def __eq__(self, other) -> bool: ... def __eq__(self, other: object) -> bool: ...
def __int__(self) -> int: ... def __int__(self) -> int: ...
_SignalKind = TypeVar("_SignalKind", bool, int, float, covariant=True) _SignalKind = TypeVar("_SignalKind", bool, int, float, covariant=True)
@ -151,7 +151,7 @@ class BoolSignal(Signal[bool]):
def constant(cls, value: bool) -> Self: ... def constant(cls, value: bool) -> Self: ...
@classmethod @classmethod
def from_samples(cls, samples: list[tuple[float, bool]]) -> Self: ... def from_samples(cls, samples: list[tuple[float, bool]]) -> Self: ...
def push(self, time: float, value: bool): ... def push(self, time: float, value: bool) -> None: ...
def at(self, time: float) -> _SignalKind | None: ... def at(self, time: float) -> _SignalKind | None: ...
@final @final
@ -160,7 +160,7 @@ class IntSignal(Signal[int]):
def constant(cls, value: int) -> Self: ... def constant(cls, value: int) -> Self: ...
@classmethod @classmethod
def from_samples(cls, samples: list[tuple[float, int]]) -> Self: ... def from_samples(cls, samples: list[tuple[float, int]]) -> Self: ...
def push(self, time: float, value: int): ... def push(self, time: float, value: int) -> None: ...
def at(self, time: float) -> int | None: ... def at(self, time: float) -> int | None: ...
@final @final
@ -169,7 +169,7 @@ class UnsignedIntSignal(Signal[int]):
def constant(cls, value: int) -> Self: ... def constant(cls, value: int) -> Self: ...
@classmethod @classmethod
def from_samples(cls, samples: list[tuple[float, int]]) -> Self: ... def from_samples(cls, samples: list[tuple[float, int]]) -> Self: ...
def push(self, time: float, value: int): ... def push(self, time: float, value: int) -> None: ...
def at(self, time: float) -> int | None: ... def at(self, time: float) -> int | None: ...
@final @final
@ -178,7 +178,7 @@ class FloatSignal(Signal[float]):
def constant(cls, value: float) -> Self: ... def constant(cls, value: float) -> Self: ...
@classmethod @classmethod
def from_samples(cls, samples: list[tuple[float, float]]) -> Self: ... def from_samples(cls, samples: list[tuple[float, float]]) -> Self: ...
def push(self, time: float, value: float): ... def push(self, time: float, value: float) -> None: ...
def at(self, time: float) -> float | None: ... def at(self, time: float) -> float | None: ...
@final @final

View file

@ -46,8 +46,12 @@ show_error_codes = true
[tool.ruff] [tool.ruff]
line-length = 127 line-length = 127
select = ["E", "F", "W", "N"] select = ["E", "F", "W", "N", "B", "ANN", "PYI"]
ignore = ["F403"] ignore = ["ANN101", "ANN102"]
[tool.ruff.per-file-ignores]
"*.py" = ["B905", "E203", "E501", "W291", "W293"]
"*.pyi" = ["B", "E501", "E701"]
[tool.flake8] [tool.flake8]
max-line-length = 127 max-line-length = 127

View file

@ -1,4 +1,4 @@
from typing import List, Type, Union from typing import List, Tuple, Type, Union
import pytest import pytest
from hypothesis import Verbosity, given, note, settings from hypothesis import Verbosity, given, note, settings
@ -11,7 +11,9 @@ AllowedDtype = Union[bool, int, float]
@composite @composite
def gen_samples(draw: st.DrawFn, *, min_size: int, max_size: int, dtype: Type[AllowedDtype]): def gen_samples(
draw: st.DrawFn, *, min_size: int, max_size: int, dtype: Type[AllowedDtype]
) -> List[Tuple[float, AllowedDtype]]:
""" """
Generate arbitrary samples for a signal where the time stamps are strictly Generate arbitrary samples for a signal where the time stamps are strictly
monotonically increasing monotonically increasing
@ -53,7 +55,6 @@ def gen_dtype() -> SearchStrategy[Type[AllowedDtype]]:
return st.one_of(st.just(bool), st.just(int), st.just(float)) return st.one_of(st.just(bool), st.just(int), st.just(float))
@settings(verbosity=Verbosity.verbose)
@given(st.data()) @given(st.data())
def test_correctly_create_signals(data: st.DataObject) -> None: def test_correctly_create_signals(data: st.DataObject) -> None:
dtype = data.draw(gen_dtype()) dtype = data.draw(gen_dtype())