Skip to content

Commit 15bf791

Browse files
authored
chore(python): Add license header to generated stubs (#470)
Fixes the CI error after merging #468 https://github.com/apache/arrow-nanoarrow/actions/runs/9099842452/job/25013337430?pr=461#step:4:11
1 parent 68136a7 commit 15bf791

File tree

3 files changed

+79
-3
lines changed

3 files changed

+79
-3
lines changed

python/generate_type_stubs.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,34 @@ SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2424
pushd "${SOURCE_DIR}"
2525

2626
# Generate stubs using mypy
27-
stubgen --module nanoarrow._lib --include-docstrings -o src
28-
stubgen --module nanoarrow._ipc_lib --include-docstrings -o src
27+
stubgen --module nanoarrow._lib --include-docstrings -o build/tmp
28+
stubgen --module nanoarrow._ipc_lib --include-docstrings -o build/tmp
29+
30+
# Add license to the start of the files
31+
LICENSE='
32+
# Licensed to the Apache Software Foundation (ASF) under one
33+
# or more contributor license agreements. See the NOTICE file
34+
# distributed with this work for additional information
35+
# regarding copyright ownership. The ASF licenses this file
36+
# to you under the Apache License, Version 2.0 (the
37+
# "License"); you may not use this file except in compliance
38+
# with the License. You may obtain a copy of the License at
39+
#
40+
# http://www.apache.org/licenses/LICENSE-2.0
41+
#
42+
# Unless required by applicable law or agreed to in writing,
43+
# software distributed under the License is distributed on an
44+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
45+
# KIND, either express or implied. See the License for the
46+
# specific language governing permissions and limitations
47+
# under the License.
48+
'
49+
50+
echo "$LICENSE" > src/nanoarrow/_lib.pyi
51+
cat build/tmp/nanoarrow/_lib.pyi >> src/nanoarrow/_lib.pyi
52+
53+
echo "$LICENSE" > src/nanoarrow/_ipc_lib.pyi
54+
cat build/tmp/nanoarrow/_ipc_lib.pyi >> src/nanoarrow/_ipc_lib.pyi
2955

3056
# Reformat stubs
3157
black src/nanoarrow/*.pyi

python/src/nanoarrow/_ipc_lib.pyi

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
118
import _cython_3_0_10
219
from _typeshed import Incomplete
320

@@ -23,6 +40,10 @@ class PyInputStreamPrivate:
2340
def __init__(cls, *args, **kwargs) -> None:
2441
"""Create and return a new object. See help(type) for accurate signature."""
2542
def set_buffer(self, *args, **kwargs): ...
43+
def __buffer__(self, *args, **kwargs):
44+
"""Return a buffer object that exposes the underlying memory of the object."""
2645
def __len__(self) -> int:
2746
"""Return len(self)."""
2847
def __reduce__(self): ...
48+
def __release_buffer__(self, *args, **kwargs):
49+
"""Release the buffer object that exposes the underlying memory of the object."""

python/src/nanoarrow/_lib.pyi

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
118
import _cython_3_0_10
219
import enum
320
import types
@@ -231,13 +248,17 @@ class CBuffer:
231248
def empty(*args, **kwargs): ...
232249
@staticmethod
233250
def from_pybuffer(*args, **kwargs): ...
251+
def __buffer__(self, *args, **kwargs):
252+
"""Return a buffer object that exposes the underlying memory of the object."""
234253
def __getitem__(self, index):
235254
"""Return self[key]."""
236255
def __iter__(self):
237256
"""Implement iter(self)."""
238257
def __len__(self) -> int:
239258
"""Return len(self)."""
240259
def __reduce__(self): ...
260+
def __release_buffer__(self, *args, **kwargs):
261+
"""Release the buffer object that exposes the underlying memory of the object."""
241262

242263
class CBufferBuilder:
243264
__pyx_vtable__: ClassVar[PyCapsule] = ...
@@ -289,7 +310,11 @@ class CBufferBuilder:
289310
290311
This method returns the number of elements that were written.
291312
"""
313+
def __buffer__(self, *args, **kwargs):
314+
"""Return a buffer object that exposes the underlying memory of the object."""
292315
def __reduce__(self): ...
316+
def __release_buffer__(self, *args, **kwargs):
317+
"""Release the buffer object that exposes the underlying memory of the object."""
293318

294319
class CBufferView:
295320
__pyx_vtable__: ClassVar[PyCapsule] = ...
@@ -310,13 +335,17 @@ class CBufferView:
310335
def elements(self, *args, **kwargs): ...
311336
def unpack_bits(self, *args, **kwargs): ...
312337
def unpack_bits_into(self, *args, **kwargs): ...
338+
def __buffer__(self, *args, **kwargs):
339+
"""Return a buffer object that exposes the underlying memory of the object."""
313340
def __getitem__(self, index):
314341
"""Return self[key]."""
315342
def __iter__(self):
316343
"""Implement iter(self)."""
317344
def __len__(self) -> int:
318345
"""Return len(self)."""
319346
def __reduce__(self): ...
347+
def __release_buffer__(self, *args, **kwargs):
348+
"""Release the buffer object that exposes the underlying memory of the object."""
320349

321350
class CDeviceArray:
322351
array: Incomplete
@@ -521,7 +550,7 @@ class SchemaMetadata:
521550
def keys(self, *args, **kwargs): ...
522551
def values(self, *args, **kwargs): ...
523552
def __contains__(self, other) -> bool:
524-
"""Return key in self."""
553+
"""Return bool(key in self)."""
525554
def __getitem__(self, index):
526555
"""Return self[key]."""
527556
def __iter__(self):

0 commit comments

Comments
 (0)