Skip to content

Commit

Permalink
Fix circular import in vec.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
MylesBartlett committed Aug 1, 2024
1 parent b6b6c97 commit 5b81bcb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
13 changes: 11 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions serox/iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = [
Expand Down
7 changes: 6 additions & 1 deletion serox/vec.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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",
]
Expand Down Expand Up @@ -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()):
Expand Down

0 comments on commit 5b81bcb

Please sign in to comment.