-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add more ruff rules Signed-off-by: 盐粒 Yanli <[email protected]> * chore: modified readme Signed-off-by: 盐粒 Yanli <[email protected]> * rename error class Signed-off-by: 盐粒 Yanli <[email protected]> --------- Signed-off-by: 盐粒 Yanli <[email protected]>
- Loading branch information
1 parent
f8344dd
commit f6e382d
Showing
16 changed files
with
138 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,7 @@ pdm sync | |
Run lint: | ||
```bash | ||
pdm run format | ||
pdm run fix | ||
pdm run check | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ name = "pgvecto-rs" | |
version = "0.1.3" | ||
description = "Python binding for pgvecto.rs" | ||
authors = [ | ||
{ name = "TensorChord", email = "[email protected]" }, | ||
{ name = "盐粒 Yanli", email = "[email protected]" }, | ||
{ name = "TensorChord", email = "[email protected]" }, | ||
{ name = "盐粒 Yanli", email = "[email protected]" }, | ||
] | ||
dependencies = [ | ||
"numpy>=1.23", | ||
|
@@ -23,15 +23,15 @@ classifiers = [ | |
|
||
[build-system] | ||
build-backend = "pdm.backend" | ||
requires = [ | ||
requires = [ | ||
"pdm-backend", | ||
] | ||
|
||
[project.optional-dependencies] | ||
psycopg3 = [ | ||
psycopg3 = [ | ||
"psycopg[binary]>=3.1.12", | ||
] | ||
sdk = [ | ||
sdk = [ | ||
"openai>=1.2.2", | ||
"pgvecto_rs[sqlalchemy]", | ||
] | ||
|
@@ -40,19 +40,34 @@ sqlalchemy = [ | |
"SQLAlchemy>=2.0.23", | ||
] | ||
[tool.pdm.dev-dependencies] | ||
lint = ["ruff>=0.1.1"] | ||
lint = ["ruff>=0.1.5"] | ||
test = ["pytest>=7.4.3"] | ||
|
||
[tool.pdm.scripts] | ||
test = "pytest tests/" | ||
test = "pytest tests/" | ||
format = "ruff format ." | ||
fix = "ruff --fix ." | ||
check = { composite = ["ruff format . --check", "ruff ."] } | ||
fix = "ruff --fix ." | ||
check = { composite = ["ruff format . --check", "ruff ."] } | ||
|
||
[tool.ruff] | ||
select = ["E", "F", "I", "TID"] | ||
ignore = ["E731", "E501"] | ||
src = ["src"] | ||
select = [ | ||
"E", #https://docs.astral.sh/ruff/rules/#error-e | ||
"F", #https://docs.astral.sh/ruff/rules/#pyflakes-f | ||
"I", #https://docs.astral.sh/ruff/rules/#isort-i | ||
"TID", #https://docs.astral.sh/ruff/rules/#flake8-tidy-imports-tid | ||
"S", #https://docs.astral.sh/ruff/rules/#flake8-bandit-s | ||
"B", #https://docs.astral.sh/ruff/rules/#flake8-bugbear-b | ||
"SIM", #https://docs.astral.sh/ruff/rules/#flake8-simplify-sim | ||
"N", #https://docs.astral.sh/ruff/rules/#pep8-naming-n | ||
"PT", #https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt | ||
"TRY", #https://docs.astral.sh/ruff/rules/#tryceratops-try | ||
"FLY", #https://docs.astral.sh/ruff/rules/#flynt-fly | ||
"PL", #https://docs.astral.sh/ruff/rules/#pylint-pl | ||
"NPY", #https://docs.astral.sh/ruff/rules/#numpy-specific-rules-npy | ||
"RUF", #https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf | ||
] | ||
ignore = ["S101", "E731", "E501"] | ||
src = ["src"] | ||
|
||
[tool.pytest.ini_options] | ||
addopts = "-r aR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import numpy as np | ||
|
||
|
||
class PGVectoRsError(ValueError): | ||
pass | ||
|
||
|
||
class NDArrayDimensionError(PGVectoRsError): | ||
def __init__(self, dim: int) -> None: | ||
super().__init__(f"ndarray must be 1D for vector, got {dim}D") | ||
|
||
|
||
class NDArrayDtypeError(PGVectoRsError): | ||
def __init__(self, dtype: np.dtype) -> None: | ||
super().__init__(f"ndarray data type must be numeric for vector, got {dtype}") | ||
|
||
|
||
class BuiltinListTypeError(PGVectoRsError): | ||
def __init__(self) -> None: | ||
super().__init__("list data type must be numeric for vector") | ||
|
||
|
||
class VectorDimensionError(PGVectoRsError): | ||
def __init__(self, dim: int) -> None: | ||
super().__init__(f"vector dimension must be > 0, got {dim}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.