From 5b81bcb7d4193565cefcce326cef5ad23adb844a Mon Sep 17 00:00:00 2001 From: MylesBartlett Date: Thu, 1 Aug 2024 23:22:28 +0100 Subject: [PATCH] Fix circular import in vec.py. --- .pre-commit-config.yaml | 13 +++++++++++-- Makefile | 4 ++++ serox/iter.py | 4 ++-- serox/vec.py | 7 ++++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad516cf..8ff7db1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,11 +17,20 @@ repos: - repo: local hooks: - - id: make-pre-commit - name: Make pre-commit + - id: make-fmt + name: Make fmt description: Formats files using the `make fmt` command entry: make fmt language: system pass_filenames: false require_serial: true stages: [commit, merge-commit, push, manual] + + - id: make-test + name: Make test + description: Run tests using the `make test` command + entry: make test + language: system + pass_filenames: false + require_serial: true + stages: [commit, merge-commit, push, manual] diff --git a/Makefile b/Makefile index 2f6e8d3..731d627 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,10 @@ fmt: ## Run formatters lint: ## Run linters @. ./scripts/lint.sh +.PHONY: test +test: ## Run tests + @rye test + .PHONY: pre-commit pre-commit: ## Run pre-commit hooks @rye run pre-commit run diff --git a/serox/iter.py b/serox/iter.py index 57657c4..d50cff9 100644 --- a/serox/iter.py +++ b/serox/iter.py @@ -29,8 +29,8 @@ from serox.misc import SelfAddable, SelfMultiplicable if TYPE_CHECKING: - from .option import Null, Option, Some - from .result import Result + from serox.option import Null, Option, Some + from serox.result import Result __all__ = [ diff --git a/serox/vec.py b/serox/vec.py index 68b5184..4fb6dc2 100644 --- a/serox/vec.py +++ b/serox/vec.py @@ -1,9 +1,9 @@ from __future__ import annotations # noqa: I001 from dataclasses import dataclass -from serox import Range from random import Random as Rng from .common import True_, False_ from typing import ( + TYPE_CHECKING, Any, Callable, Generator, @@ -34,6 +34,9 @@ from serox.misc import Clone, SizedIndexable from serox.option import Null, Option, Some +if TYPE_CHECKING: + from serox import Range + __all__ = [ "Vec", ] @@ -162,6 +165,8 @@ def get(self, index: int | Range[Any], /) -> Option[T] | Option[Vec[T]]: - If given a range, returns the sub-vector corresponding to that range, or `Null` if out of bounds. """ + from serox import Range + match index: case Range(): if index.contains(self.len()):