Skip to content

Commit

Permalink
Update pyproject.toml.
Browse files Browse the repository at this point in the history
  • Loading branch information
MylesBartlett committed Jul 22, 2024
1 parent f64d0e1 commit 5b456b0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 37 deletions.
32 changes: 2 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "serox"
version = "0.1.0"
description = "Primitives for Rustifying Python"
description = "Serpentine Oxidation: Rusty primitives for Python"
keywords = [
"iterators",
"option",
Expand All @@ -14,7 +14,7 @@ keywords = [
"types",
"typing",
]
authors = [{ name = "Astute AI" }]
authors = [{ name = "Myles Bartlett" }]
classifiers = [
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
Expand Down Expand Up @@ -78,34 +78,6 @@ fmt = { chain = ["fmt:imports", "fmt:main"] }
"fmt:imports" = "rye run ruff check --select I --fix"
"fmt:main" = "rye fmt -a"

# lint = { chain = ["lint:black", "lint:flake8" ] }
# "lint:black" = "black --check src"
# "lint:flake8" = "flake8 src"

[tool.black]
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.undodir
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
)
'''
include = '\.pyi?$'
line-length = 100
skip-string-normalization = true
target-version = ['py310']

[tool.ruff]
format.docstring-code-format = true
line-length = 100
lint.ignore = [
Expand Down
3 changes: 2 additions & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"$schema": "pyrightconfig.schema.json",
"include": [
"serox/"
"serox/**"
],
"exclude": [
"**/.",
"**/__pycache__",
"**/node_modules",
".venv",
"**/.cache"
],
Expand Down
8 changes: 6 additions & 2 deletions serox/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ 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: 3 additions & 1 deletion serox/iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ 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: 3 additions & 1 deletion serox/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ 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
13 changes: 11 additions & 2 deletions serox/vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
from serox.fmt import Debug
from serox.question_mark import qmark
from serox.result import ErrShortCircuit, Ok, Result, Err
from .iter import DoubleEndedIterator, FromIterator, IntoIterator, IntoParIterator, Iterator, Extend
from .iter import (
DoubleEndedIterator,
FromIterator,
IntoIterator,
IntoParIterator,
Iterator,
Extend,
)
from .cmp import PartialOrd
from .default import Default

Expand Down Expand Up @@ -170,7 +177,9 @@ 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 5b456b0

Please sign in to comment.