Skip to content

Commit

Permalink
Reinstate key.
Browse files Browse the repository at this point in the history
  • Loading branch information
MylesBartlett committed Jul 22, 2024
1 parent 5b456b0 commit 11ddff0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ fmt = { chain = ["fmt:imports", "fmt:main"] }
"fmt:imports" = "rye run ruff check --select I --fix"
"fmt:main" = "rye fmt -a"

[tool.ruff]
format.docstring-code-format = true
line-length = 100
lint.ignore = [
Expand Down
8 changes: 2 additions & 6 deletions serox/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ class DataclassInstance(Protocol):
def shallow_astuple(dc: DataclassInstance, /) -> Result[tuple[Any, ...], TypeError]:
"""dataclasses.astuple() but without the deep-copying/recursion." """
if not is_dataclass(dataclass):
return Err(
TypeError("shallow_astuple() should be called on dataclass instances")
)
return Err(TypeError("shallow_astuple() should be called on dataclass instances"))
return Ok(tuple(getattr(dc, field_.name) for field_ in fields(dc)))


def shallow_asdict(dc: DataclassInstance, /) -> Result[dict[str, Any], TypeError]:
"""dataclasses.asdict() but without the deep-copying/recursion." """
if not is_dataclass(dc):
return Err(
TypeError("shallow_asdict() should be called on dataclass instances")
)
return Err(TypeError("shallow_asdict() should be called on dataclass instances"))
return Ok({field_.name: getattr(dc, field_.name) for field_ in fields(dc)})
4 changes: 1 addition & 3 deletions serox/iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ def __iter__(self) -> Generator[Item, None, None]:
if self.par:
yield from cast(
Generator[Item, None, None],
Parallel(n_jobs=-1, verbose=0)(
delayed(_identity)(i) for i in self._iter()
),
Parallel(n_jobs=-1, verbose=0)(delayed(_identity)(i) for i in self._iter()),
)
else:
yield from self._iter()
Expand Down
4 changes: 1 addition & 3 deletions serox/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ def next_back(self) -> Option[Idx]:
return Null()

@classmethod
def from_sized(
cls, sized: Sized, /, start: int = 0, *, par: P2 = False
) -> Range[P2]:
def from_sized(cls, sized: Sized, /, start: int = 0, *, par: P2 = False) -> Range[P2]:
return Range[P2](start, len(sized), par=par)

def contains(self, item: Idx, /) -> bool:
Expand Down
4 changes: 1 addition & 3 deletions serox/vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ def pop(self) -> Option[T]:

def remove(self, index: int) -> T:
if index >= self.len():
raise IndexError(
f"removal index (is {index}) should be < len (is {self.len()})"
)
raise IndexError(f"removal index (is {index}) should be < len (is {self.len()})")
return self.inner.pop(index)

def insert(self, index: int, element: T) -> None:
Expand Down

0 comments on commit 11ddff0

Please sign in to comment.