This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git
The following commit(s) were added to refs/heads/main by this push:
new 15bf7910 chore(python): Add license header to generated stubs (#470)
15bf7910 is described below
commit 15bf791073d9862e3db88193ab5a4242faecae58
Author: Dewey Dunnington <[email protected]>
AuthorDate: Wed May 15 14:25:17 2024 -0300
chore(python): Add license header to generated stubs (#470)
Fixes the CI error after merging
https://github.com/apache/arrow-nanoarrow/pull/468
https://github.com/apache/arrow-nanoarrow/actions/runs/9099842452/job/25013337430?pr=461#step:4:11
---
python/generate_type_stubs.sh | 30 ++++++++++++++++++++++++++++--
python/src/nanoarrow/_ipc_lib.pyi | 21 +++++++++++++++++++++
python/src/nanoarrow/_lib.pyi | 31 ++++++++++++++++++++++++++++++-
3 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/python/generate_type_stubs.sh b/python/generate_type_stubs.sh
index 9776778f..2a8aec60 100755
--- a/python/generate_type_stubs.sh
+++ b/python/generate_type_stubs.sh
@@ -24,8 +24,34 @@ SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd
)"
pushd "${SOURCE_DIR}"
# Generate stubs using mypy
-stubgen --module nanoarrow._lib --include-docstrings -o src
-stubgen --module nanoarrow._ipc_lib --include-docstrings -o src
+stubgen --module nanoarrow._lib --include-docstrings -o build/tmp
+stubgen --module nanoarrow._ipc_lib --include-docstrings -o build/tmp
+
+# Add license to the start of the files
+LICENSE='
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+'
+
+echo "$LICENSE" > src/nanoarrow/_lib.pyi
+cat build/tmp/nanoarrow/_lib.pyi >> src/nanoarrow/_lib.pyi
+
+echo "$LICENSE" > src/nanoarrow/_ipc_lib.pyi
+cat build/tmp/nanoarrow/_ipc_lib.pyi >> src/nanoarrow/_ipc_lib.pyi
# Reformat stubs
black src/nanoarrow/*.pyi
diff --git a/python/src/nanoarrow/_ipc_lib.pyi
b/python/src/nanoarrow/_ipc_lib.pyi
index 300cc977..dcd2abdf 100644
--- a/python/src/nanoarrow/_ipc_lib.pyi
+++ b/python/src/nanoarrow/_ipc_lib.pyi
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
import _cython_3_0_10
from _typeshed import Incomplete
@@ -23,6 +40,10 @@ class PyInputStreamPrivate:
def __init__(cls, *args, **kwargs) -> None:
"""Create and return a new object. See help(type) for accurate
signature."""
def set_buffer(self, *args, **kwargs): ...
+ def __buffer__(self, *args, **kwargs):
+ """Return a buffer object that exposes the underlying memory of the
object."""
def __len__(self) -> int:
"""Return len(self)."""
def __reduce__(self): ...
+ def __release_buffer__(self, *args, **kwargs):
+ """Release the buffer object that exposes the underlying memory of the
object."""
diff --git a/python/src/nanoarrow/_lib.pyi b/python/src/nanoarrow/_lib.pyi
index 24f1f61a..31d2d0a6 100644
--- a/python/src/nanoarrow/_lib.pyi
+++ b/python/src/nanoarrow/_lib.pyi
@@ -1,3 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
import _cython_3_0_10
import enum
import types
@@ -231,6 +248,8 @@ class CBuffer:
def empty(*args, **kwargs): ...
@staticmethod
def from_pybuffer(*args, **kwargs): ...
+ def __buffer__(self, *args, **kwargs):
+ """Return a buffer object that exposes the underlying memory of the
object."""
def __getitem__(self, index):
"""Return self[key]."""
def __iter__(self):
@@ -238,6 +257,8 @@ class CBuffer:
def __len__(self) -> int:
"""Return len(self)."""
def __reduce__(self): ...
+ def __release_buffer__(self, *args, **kwargs):
+ """Release the buffer object that exposes the underlying memory of the
object."""
class CBufferBuilder:
__pyx_vtable__: ClassVar[PyCapsule] = ...
@@ -289,7 +310,11 @@ class CBufferBuilder:
This method returns the number of elements that were written.
"""
+ def __buffer__(self, *args, **kwargs):
+ """Return a buffer object that exposes the underlying memory of the
object."""
def __reduce__(self): ...
+ def __release_buffer__(self, *args, **kwargs):
+ """Release the buffer object that exposes the underlying memory of the
object."""
class CBufferView:
__pyx_vtable__: ClassVar[PyCapsule] = ...
@@ -310,6 +335,8 @@ class CBufferView:
def elements(self, *args, **kwargs): ...
def unpack_bits(self, *args, **kwargs): ...
def unpack_bits_into(self, *args, **kwargs): ...
+ def __buffer__(self, *args, **kwargs):
+ """Return a buffer object that exposes the underlying memory of the
object."""
def __getitem__(self, index):
"""Return self[key]."""
def __iter__(self):
@@ -317,6 +344,8 @@ class CBufferView:
def __len__(self) -> int:
"""Return len(self)."""
def __reduce__(self): ...
+ def __release_buffer__(self, *args, **kwargs):
+ """Release the buffer object that exposes the underlying memory of the
object."""
class CDeviceArray:
array: Incomplete
@@ -521,7 +550,7 @@ class SchemaMetadata:
def keys(self, *args, **kwargs): ...
def values(self, *args, **kwargs): ...
def __contains__(self, other) -> bool:
- """Return key in self."""
+ """Return bool(key in self)."""
def __getitem__(self, index):
"""Return self[key]."""
def __iter__(self):