Skip to content

Commit 51b69e3

Browse files
committed
Switch to stringdtype name; use ruff instead of flake8
1 parent 40e3a91 commit 51b69e3

File tree

19 files changed

+113
-325
lines changed

19 files changed

+113
-325
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,5 @@ dmypy.json
130130

131131
.mesonpy-native-file.ini
132132
compile_commands.json
133+
134+
.ruff-cache/

.pre-commit-config.yaml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ repos:
3333
entry: |
3434
bash -c 'cd unytdtype && mkdir -p build && pip install build meson-python patchelf wheel && python -m build --wheel --no-isolation -Cbuilddir=build';
3535
fail_fast: false
36-
- id: generate-compilation-database-strptrdtype
37-
name: Generate compilation database [strptrdtype]
38-
files: strptrdtype/(meson\.build$|.*\.(c|h)$)
36+
- id: generate-compilation-database-stringdtype
37+
name: Generate compilation database [stringdtype]
38+
files: stringdtype/(meson\.build$|.*\.(c|h)$)
3939
language: system
4040
require_serial: true
4141
entry: |
42-
bash -c 'cd strptrdtype && mkdir -p build && pip install build meson-python patchelf wheel && python -m build --wheel --no-isolation -Cbuilddir=build';
42+
bash -c 'cd stringdtype && mkdir -p build && pip install build meson-python patchelf wheel && python -m build --wheel --no-isolation -Cbuilddir=build';
4343
fail_fast: false
4444
- repo: https://github.com/pocc/pre-commit-hooks
4545
rev: v1.3.5
@@ -56,33 +56,30 @@ repos:
5656
name: clang-tidy [unytdtype]
5757
args: [-p=unytdtype/build]
5858
files: unytdtype/(.*\.(c|h)$)
59+
- id: clang-tidy
60+
name: clang-tidy [stringdtype]
61+
args: [-p=stringdtype/build]
62+
files: stringdtype/(.*\.(c|h)$)
5963
- id: clang-format
6064
args: ['--no-diff', -i]
6165
# - id: oclint
6266
# - id: cppcheck
6367
- repo: https://github.com/pre-commit/pre-commit-hooks
64-
rev: v4.3.0
68+
rev: v4.4.0
6569
hooks:
6670
- id: trailing-whitespace
6771
- id: end-of-file-fixer
6872
- id: check-yaml
6973
- id: check-added-large-files
7074
- id: check-ast
71-
- repo: https://github.com/pycqa/flake8
72-
rev: 3.9.2
75+
- repo: https://github.com/charliermarsh/ruff-pre-commit
76+
rev: v0.0.217
7377
hooks:
74-
- id: flake8
75-
additional_dependencies:
76-
[
77-
flake8-mutable,
78-
flake8-debugger,
79-
flake8-pytest-style,
80-
flake8-simplify,
81-
pep8-naming,
82-
darglint,
83-
]
78+
- id: ruff
79+
# Respect `exclude` and `extend-exclude` settings.
80+
args: ["--force-exclude"]
8481
- repo: https://github.com/pre-commit/mirrors-prettier
85-
rev: v3.0.0-alpha.0
82+
rev: v3.0.0-alpha.4
8683
hooks:
8784
- id: prettier
8885
types:
@@ -91,7 +88,7 @@ repos:
9188
yaml,
9289
]
9390
- repo: https://github.com/pycqa/isort
94-
rev: 5.10.1
91+
rev: 5.11.4
9592
hooks:
9693
- id: isort
9794
name: isort (python)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project(
2-
'strptrdtype',
2+
'stringdtype',
33
'c',
44
)
55

@@ -17,32 +17,32 @@ incdir_numpy = run_command(py,
1717
includes = include_directories(
1818
[
1919
incdir_numpy,
20-
'strptrdtype/src'
20+
'stringdtype/src'
2121
]
2222
)
2323

2424
srcs = [
25-
'strptrdtype/src/casts.c',
26-
'strptrdtype/src/casts.h',
27-
'strptrdtype/src/dtype.c',
28-
'strptrdtype/src/main.c',
29-
# 'strptrdtype/src/umath.c',
30-
# 'strptrdtype/src/umath.h',
25+
'stringdtype/src/casts.c',
26+
'stringdtype/src/casts.h',
27+
'stringdtype/src/dtype.c',
28+
'stringdtype/src/main.c',
29+
# 'stringdtype/src/umath.c',
30+
# 'stringdtype/src/umath.h',
3131
]
3232

3333
py.install_sources(
3434
[
35-
'strptrdtype/__init__.py',
36-
'strptrdtype/scalar.py'
35+
'stringdtype/__init__.py',
36+
'stringdtype/scalar.py'
3737
],
38-
subdir: 'strptrdtype'
38+
subdir: 'stringdtype'
3939
)
4040

4141
py.extension_module(
4242
'_main',
4343
srcs,
4444
c_args: ['-g', '-O0', '-pg'],
4545
install: true,
46-
subdir: 'strptrdtype',
46+
subdir: 'stringdtype',
4747
include_directories: includes
4848
)

strptrdtype/pyproject.toml renamed to stringdtype/pyproject.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@ build-backend = "mesonpy"
1212
line-length = 79
1313

1414
[project]
15-
name = "strptrdtype"
16-
description = "A dtype for storing string pointers data"
15+
name = "stringdtype"
16+
description = "A dtype for storing UTF-8 strings"
1717
version = "0.0.1"
1818
readme = 'README.md'
19-
author = "Peyton Murray"
19+
authors = [
20+
{ name = "Nathan Goldbaum" },
21+
{ name = "Peyton Murray" }
22+
]
2023
requires-python = ">=3.9.0"
2124
dependencies = [
2225
"numpy",
2326
]
27+
28+
[tool.ruff]
29+
line-length = 79
30+
per-file-ignores = {"__init__.py" = ["F401"]}

strptrdtype/strptrdtype/__init__.py renamed to stringdtype/stringdtype/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
in Numpy and is not intended for any real purpose.
55
"""
66

7-
from .scalar import StrPtrScalar # isort: skip
8-
from ._main import StrPtrDType
7+
from .scalar import StringScalar # isort: skip
8+
from ._main import StringDType
99

10-
__all__ = ["StrPtrDType", "StrScalar"]
10+
__all__ = ["StringDType", "StringScalar"]

strptrdtype/strptrdtype/scalar.py renamed to stringdtype/stringdtype/scalar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""A scalar type needed by the dtype machinery."""
22

33

4-
class StrPtrScalar:
4+
class StringScalar:
55
def __init__(self, value):
66
self.value = value
77

strptrdtype/strptrdtype/src/casts.c renamed to stringdtype/stringdtype/src/casts.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// From https://numpy.org/neps/nep-0043-extensible-ufuncs.html#arraymethod:
1212
// resolve_descriptors returns the safety of the operation (casting safety)
1313
static NPY_CASTING
14-
strptr_to_strptr_resolve_descriptors(PyObject *NPY_UNUSED(self),
14+
string_to_string_resolve_descriptors(PyObject *NPY_UNUSED(self),
1515
PyArray_DTypeMeta *NPY_UNUSED(dtypes[2]),
1616
PyArray_Descr *given_descrs[2],
1717
PyArray_Descr *loop_descrs[2],
@@ -33,7 +33,7 @@ strptr_to_strptr_resolve_descriptors(PyObject *NPY_UNUSED(self),
3333
}
3434

3535
static int
36-
strptr_to_strptr(PyArrayMethod_Context *NPY_UNUSED(context),
36+
string_to_string(PyArrayMethod_Context *NPY_UNUSED(context),
3737
char **const data[], npy_intp const dimensions[],
3838
npy_intp const strides[], NpyAuxData *NPY_UNUSED(auxdata))
3939
{
@@ -55,13 +55,13 @@ strptr_to_strptr(PyArrayMethod_Context *NPY_UNUSED(context),
5555
static PyArray_DTypeMeta *a2a_dtypes[2] = {NULL, NULL};
5656

5757
static PyType_Slot a2a_slots[] = {
58-
{NPY_METH_resolve_descriptors, &strptr_to_strptr_resolve_descriptors},
59-
{NPY_METH_strided_loop, &strptr_to_strptr},
60-
{NPY_METH_unaligned_strided_loop, &strptr_to_strptr},
58+
{NPY_METH_resolve_descriptors, &string_to_string_resolve_descriptors},
59+
{NPY_METH_strided_loop, &string_to_string},
60+
{NPY_METH_unaligned_strided_loop, &string_to_string},
6161
{0, NULL}};
6262

63-
PyArrayMethod_Spec StrPtrToStrPtrCastSpec = {
64-
.name = "cast_StrPtrDType_to_StrPtrDType",
63+
PyArrayMethod_Spec StringToStringCastSpec = {
64+
.name = "cast_StringDType_to_StringDType",
6565
.nin = 1,
6666
.nout = 1,
6767
.casting = NPY_UNSAFE_CASTING,
@@ -74,7 +74,7 @@ PyArrayMethod_Spec **
7474
get_casts(void)
7575
{
7676
PyArrayMethod_Spec **casts = malloc(2 * sizeof(PyArrayMethod_Spec *));
77-
casts[0] = &StrPtrToStrPtrCastSpec;
77+
casts[0] = &StringToStringCastSpec;
7878
casts[1] = NULL;
7979

8080
return casts;

0 commit comments

Comments
 (0)