arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-1093: [Python] Run flake8 in Travis CI. Add note about development to README
Date Wed, 02 Aug 2017 02:50:26 GMT
Repository: arrow
Updated Branches:
  refs/heads/master aa1d753a7 -> e5ed31fc5


ARROW-1093: [Python] Run flake8 in Travis CI. Add note about development to README

Author: Wes McKinney <wes.mckinney@twosigma.com>

Closes #924 from wesm/ARROW-1093 and squashes the following commits:

75969c37 [Wes McKinney] Add spaces before continuation backslash
fa24ec92 [Wes McKinney] Specify file suffixes completely
c0af17c3 [Wes McKinney] Add flake8 file for Cython, fix Cython style errors
7ffa6135 [Wes McKinney] Add Cython flake8 file
f10e8d1f [Wes McKinney] Run flake8 in Travis CI. Add note to README


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/e5ed31fc
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/e5ed31fc
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/e5ed31fc

Branch: refs/heads/master
Commit: e5ed31fc5e903ea0a2102623413ab85577cba123
Parents: aa1d753
Author: Wes McKinney <wes.mckinney@twosigma.com>
Authored: Tue Aug 1 22:50:21 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Tue Aug 1 22:50:21 2017 -0400

----------------------------------------------------------------------
 ci/travis_script_python.sh           |  8 ++++-
 python/.flake8.cython                | 20 +++++++++++
 python/README.md                     | 19 ++++++++--
 python/pyarrow/_config.pyx           |  9 +++--
 python/pyarrow/_parquet.pxd          | 45 +++++++++++++----------
 python/pyarrow/_parquet.pyx          |  9 ++---
 python/pyarrow/array.pxi             |  9 +++--
 python/pyarrow/feather.pxi           |  2 +-
 python/pyarrow/includes/libarrow.pxd | 60 +++++++++++++++----------------
 python/pyarrow/io-hdfs.pxi           |  1 -
 python/pyarrow/io.pxi                | 10 ++++--
 python/pyarrow/ipc.pxi               |  2 +-
 python/pyarrow/lib.pxd               |  4 +--
 python/pyarrow/lib.pyx               | 23 +++++-------
 python/pyarrow/plasma.pyx            | 24 +++++++------
 python/pyarrow/public-api.pxi        | 11 +++---
 python/pyarrow/scalar.pxi            |  8 ++---
 python/pyarrow/table.pxi             |  5 ++-
 python/pyarrow/types.pxi             |  2 +-
 19 files changed, 160 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/ci/travis_script_python.sh
----------------------------------------------------------------------
diff --git a/ci/travis_script_python.sh b/ci/travis_script_python.sh
index 9135aaf..4a50d2f 100755
--- a/ci/travis_script_python.sh
+++ b/ci/travis_script_python.sh
@@ -92,7 +92,13 @@ python_version_tests() {
   conda install -y -q nomkl
 
   # Expensive dependencies install from Continuum package repo
-  conda install -y -q pip numpy pandas cython
+  conda install -y -q pip numpy pandas cython flake8
+
+  # Fail fast on style checks
+  flake8 pyarrow
+
+  # Check Cython files with some checks turned off
+  flake8 --config=.flake8.cython pyarrow
 
   # Build C++ libraries
   rebuild_arrow_libraries

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/.flake8.cython
----------------------------------------------------------------------
diff --git a/python/.flake8.cython b/python/.flake8.cython
new file mode 100644
index 0000000..53e4132
--- /dev/null
+++ b/python/.flake8.cython
@@ -0,0 +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.
+
+[flake8]
+filename = *.pyx,*.pxd,*.pxi
+ignore = E211,E901,E225,E226,E227

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/README.md
----------------------------------------------------------------------
diff --git a/python/README.md b/python/README.md
index 29d213b..3c48d5d 100644
--- a/python/README.md
+++ b/python/README.md
@@ -38,7 +38,21 @@ On Linux, you can also install binary wheels from PyPI with pip:
 pip install pyarrow
 ```
 
-### Development details
+## Development
+
+### Coding Style
+
+We follow a similar PEP8-like coding style to the [pandas project][3].
+
+The code must pass `flake8` (available from pip or conda) or it will fail the
+build. Check for style errors before submitting your pull request with:
+
+```
+flake8 pyarrow
+flake8 --config=.flake8.cython pyarrow
+```
+
+### Building from Source
 
 See the [Development][2] page in the documentation.
 
@@ -50,4 +64,5 @@ python setup.py build_sphinx -s doc/source
 ```
 
 [1]: https://github.com/apache/parquet-cpp
-[2]: https://github.com/apache/arrow/blob/master/python/doc/source/development.rst
\ No newline at end of file
+[2]: https://github.com/apache/arrow/blob/master/python/doc/source/development.rst
+[3]: https://github.com/pandas-dev/pandas
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/_config.pyx
----------------------------------------------------------------------
diff --git a/python/pyarrow/_config.pyx b/python/pyarrow/_config.pyx
index a2d2d71..bc9f36d 100644
--- a/python/pyarrow/_config.pyx
+++ b/python/pyarrow/_config.pyx
@@ -19,6 +19,10 @@
 # distutils: language = c++
 # cython: embedsignature = True
 
+import numpy as np
+import multiprocessing
+import os
+
 cdef extern from 'arrow/python/init.h':
     int arrow_init_numpy() except -1
 
@@ -27,15 +31,13 @@ cdef extern from 'arrow/python/config.h' namespace 'arrow::py':
 
 arrow_init_numpy()
 
-import numpy as np
 set_numpy_nan(np.nan)
 
-import multiprocessing
-import os
 cdef int CPU_COUNT = int(
     os.environ.get('OMP_NUM_THREADS',
                    max(multiprocessing.cpu_count() // 2, 1)))
 
+
 def cpu_count():
     """
     Returns
@@ -49,6 +51,7 @@ def cpu_count():
     """
     return CPU_COUNT
 
+
 def set_cpu_count(count):
     global CPU_COUNT
     CPU_COUNT = max(int(count), 1)

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/_parquet.pxd
----------------------------------------------------------------------
diff --git a/python/pyarrow/_parquet.pxd b/python/pyarrow/_parquet.pxd
index b1cd5eb..7299e19 100644
--- a/python/pyarrow/_parquet.pxd
+++ b/python/pyarrow/_parquet.pxd
@@ -25,17 +25,18 @@ from pyarrow.includes.libarrow cimport (CArray, CSchema, CStatus,
 
 
 cdef extern from "parquet/api/schema.h" namespace "parquet::schema" nogil:
-  cdef cppclass Node:
-    pass
+    cdef cppclass Node:
+        pass
 
-  cdef cppclass GroupNode(Node):
-    pass
+    cdef cppclass GroupNode(Node):
+        pass
 
-  cdef cppclass PrimitiveNode(Node):
-    pass
+    cdef cppclass PrimitiveNode(Node):
+        pass
+
+    cdef cppclass ColumnPath:
+        c_string ToDotString()
 
-  cdef cppclass ColumnPath:
-    c_string ToDotString()
 
 cdef extern from "parquet/api/schema.h" namespace "parquet" nogil:
     enum ParquetType" parquet::Type::type":
@@ -59,8 +60,10 @@ cdef extern from "parquet/api/schema.h" namespace "parquet" nogil:
         ParquetLogicalType_DATE" parquet::LogicalType::DATE"
         ParquetLogicalType_TIME_MILLIS" parquet::LogicalType::TIME_MILLIS"
         ParquetLogicalType_TIME_MICROS" parquet::LogicalType::TIME_MICROS"
-        ParquetLogicalType_TIMESTAMP_MILLIS" parquet::LogicalType::TIMESTAMP_MILLIS"
-        ParquetLogicalType_TIMESTAMP_MICROS" parquet::LogicalType::TIMESTAMP_MICROS"
+        ParquetLogicalType_TIMESTAMP_MILLIS \
+            " parquet::LogicalType::TIMESTAMP_MILLIS"
+        ParquetLogicalType_TIMESTAMP_MICROS \
+            " parquet::LogicalType::TIMESTAMP_MICROS"
         ParquetLogicalType_UINT_8" parquet::LogicalType::UINT_8"
         ParquetLogicalType_UINT_16" parquet::LogicalType::UINT_16"
         ParquetLogicalType_UINT_32" parquet::LogicalType::UINT_32"
@@ -83,8 +86,10 @@ cdef extern from "parquet/api/schema.h" namespace "parquet" nogil:
         ParquetEncoding_PLAIN_DICTIONARY" parquet::Encoding::PLAIN_DICTIONARY"
         ParquetEncoding_RLE" parquet::Encoding::RLE"
         ParquetEncoding_BIT_PACKED" parquet::Encoding::BIT_PACKED"
-        ParquetEncoding_DELTA_BINARY_PACKED" parquet::Encoding::DELTA_BINARY_PACKED"
-        ParquetEncoding_DELTA_LENGTH_BYTE_ARRAY" parquet::Encoding::DELTA_LENGTH_BYTE_ARRAY"
+        ParquetEncoding_DELTA_BINARY_PACKED \
+            " parquet::Encoding::DELTA_BINARY_PACKED"
+        ParquetEncoding_DELTA_LENGTH_BYTE_ARRAY \
+            " parquet::Encoding::DELTA_LENGTH_BYTE_ARRAY"
         ParquetEncoding_DELTA_BYTE_ARRAY" parquet::Encoding::DELTA_BYTE_ARRAY"
         ParquetEncoding_RLE_DICTIONARY" parquet::Encoding::RLE_DICTIONARY"
 
@@ -231,13 +236,15 @@ cdef extern from "parquet/arrow/reader.h" namespace "parquet::arrow"
nogil:
 
 
 cdef extern from "parquet/arrow/schema.h" namespace "parquet::arrow" nogil:
-    CStatus FromParquetSchema(const SchemaDescriptor* parquet_schema,
-                              const shared_ptr[const CKeyValueMetadata]& key_value_metadata,
-                              shared_ptr[CSchema]* out)
-
-    CStatus ToParquetSchema(const CSchema* arrow_schema,
-                            const shared_ptr[const CKeyValueMetadata]& key_value_metadata,
-                            shared_ptr[SchemaDescriptor]* out)
+    CStatus FromParquetSchema(
+        const SchemaDescriptor* parquet_schema,
+        const shared_ptr[const CKeyValueMetadata]& key_value_metadata,
+        shared_ptr[CSchema]* out)
+
+    CStatus ToParquetSchema(
+        const CSchema* arrow_schema,
+        const shared_ptr[const CKeyValueMetadata]& key_value_metadata,
+        shared_ptr[SchemaDescriptor]* out)
 
 
 cdef extern from "parquet/arrow/writer.h" namespace "parquet::arrow" nogil:

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/_parquet.pyx
----------------------------------------------------------------------
diff --git a/python/pyarrow/_parquet.pyx b/python/pyarrow/_parquet.pyx
index c940122..919e82c 100644
--- a/python/pyarrow/_parquet.pyx
+++ b/python/pyarrow/_parquet.pyx
@@ -279,8 +279,8 @@ cdef class ColumnSchema:
   max_repetition_level: {3}
   physical_type: {4}
   logical_type: {5}""".format(self.name, self.path, self.max_definition_level,
-                       self.max_repetition_level, physical_type,
-                       logical_type)
+                              self.max_repetition_level, physical_type,
+                              logical_type)
 
     property name:
 
@@ -514,7 +514,7 @@ cdef class ParquetReader:
 
         with nogil:
             check_status(self.reader.get()
-                         .ReadSchemaField(field_index, &carray));
+                         .ReadSchemaField(field_index, &carray))
 
         array.init(carray)
         return array
@@ -553,7 +553,8 @@ cdef class ParquetWriter:
 
     def __cinit__(self, where, Schema schema, use_dictionary=None,
                   compression=None, version=None,
-                  MemoryPool memory_pool=None, use_deprecated_int96_timestamps=False):
+                  MemoryPool memory_pool=None,
+                  use_deprecated_int96_timestamps=False):
         cdef:
             shared_ptr[FileOutputStream] filestream
             shared_ptr[WriterProperties] properties

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/array.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/array.pxi b/python/pyarrow/array.pxi
index f320cbe..cbd036c 100644
--- a/python/pyarrow/array.pxi
+++ b/python/pyarrow/array.pxi
@@ -66,8 +66,8 @@ def array(object sequence, DataType type=None, MemoryPool memory_pool=None,
     array : pyarrow.Array
     """
     cdef:
-       shared_ptr[CArray] sp_array
-       CMemoryPool* pool
+        shared_ptr[CArray] sp_array
+        CMemoryPool* pool
 
     pool = maybe_unbox_memory_pool(memory_pool)
     if type is None:
@@ -78,13 +78,13 @@ def array(object sequence, DataType type=None, MemoryPool memory_pool=None,
                 ConvertPySequence(
                     sequence, pool, &sp_array, type.sp_type
                 )
-             )
+            )
         else:
             check_status(
                 ConvertPySequence(
                     sequence, pool, &sp_array, type.sp_type, size
                 )
-             )
+            )
 
     return pyarrow_wrap_array(sp_array)
 
@@ -401,7 +401,6 @@ strides: {2}""".format(self.type, self.shape, self.strides)
             return py_strides
 
 
-
 cdef wrap_array_output(PyObject* output):
     cdef object obj = PyObject_to_object(output)
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/feather.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/feather.pxi b/python/pyarrow/feather.pxi
index 2e7cf6c..6faf2f9 100644
--- a/python/pyarrow/feather.pxi
+++ b/python/pyarrow/feather.pxi
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-#----------------------------------------------------------------------
+# ---------------------------------------------------------------------
 # Implement legacy Feather file format
 
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/includes/libarrow.pxd
----------------------------------------------------------------------
diff --git a/python/pyarrow/includes/libarrow.pxd b/python/pyarrow/includes/libarrow.pxd
index a25d7a2..3ea4873 100644
--- a/python/pyarrow/includes/libarrow.pxd
+++ b/python/pyarrow/includes/libarrow.pxd
@@ -178,7 +178,8 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
     cdef cppclass CStringType" arrow::StringType"(CDataType):
         pass
 
-    cdef cppclass CFixedSizeBinaryType" arrow::FixedSizeBinaryType"(CFixedWidthType):
+    cdef cppclass CFixedSizeBinaryType \
+            " arrow::FixedSizeBinaryType"(CFixedWidthType):
         CFixedSizeBinaryType(int byte_width)
         int byte_width()
         int bit_width()
@@ -209,7 +210,6 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
             const shared_ptr[CKeyValueMetadata]& metadata)
         shared_ptr[CField] RemoveMetadata()
 
-
     cdef cppclass CStructType" arrow::StructType"(CDataType):
         CStructType(const vector[shared_ptr[CField]]& fields)
 
@@ -309,9 +309,10 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
 
     cdef cppclass CStructArray" arrow::StructArray"(CArray):
         CStructArray(shared_ptr[CDataType] type, int64_t length,
-            vector[shared_ptr[CArray]] children,
-            shared_ptr[CBuffer] null_bitmap = nullptr, int64_t null_count = 0,
-            int64_t offset = 0)
+                     vector[shared_ptr[CArray]] children,
+                     shared_ptr[CBuffer] null_bitmap=nullptr,
+                     int64_t null_count=0,
+                     int64_t offset=0)
 
         shared_ptr[CArray] field(int pos)
         const vector[shared_ptr[CArray]] fields()
@@ -462,7 +463,6 @@ cdef extern from "arrow/io/interfaces.h" namespace "arrow::io" nogil:
 
 cdef extern from "arrow/io/file.h" namespace "arrow::io" nogil:
 
-
     cdef cppclass FileOutputStream(OutputStream):
         @staticmethod
         CStatus Open(const c_string& path, shared_ptr[FileOutputStream]* file)
@@ -479,12 +479,12 @@ cdef extern from "arrow/io/file.h" namespace "arrow::io" nogil:
 
         int file_descriptor()
 
-    cdef cppclass CMemoryMappedFile" arrow::io::MemoryMappedFile"\
-        (ReadWriteFileInterface):
+    cdef cppclass CMemoryMappedFile \
+            " arrow::io::MemoryMappedFile"(ReadWriteFileInterface):
 
         @staticmethod
         CStatus Create(const c_string& path, int64_t size,
-                     shared_ptr[CMemoryMappedFile]* file)
+                       shared_ptr[CMemoryMappedFile]* file)
 
         @staticmethod
         CStatus Open(const c_string& path, FileMode mode,
@@ -509,7 +509,7 @@ cdef extern from "arrow/io/hdfs.h" namespace "arrow::io" nogil:
         HdfsDriver driver
 
     cdef cppclass HdfsPathInfo:
-        ObjectType kind;
+        ObjectType kind
         c_string name
         c_string owner
         c_string group
@@ -563,21 +563,22 @@ cdef extern from "arrow/io/hdfs.h" namespace "arrow::io" nogil:
 
 
 cdef extern from "arrow/io/memory.h" namespace "arrow::io" nogil:
-    cdef cppclass CBufferReader" arrow::io::BufferReader"\
-        (RandomAccessFile):
+    cdef cppclass CBufferReader \
+            " arrow::io::BufferReader"(RandomAccessFile):
         CBufferReader(const shared_ptr[CBuffer]& buffer)
         CBufferReader(const uint8_t* data, int64_t nbytes)
 
-    cdef cppclass CBufferOutputStream" arrow::io::BufferOutputStream"\
-        (OutputStream):
+    cdef cppclass CBufferOutputStream \
+            " arrow::io::BufferOutputStream"(OutputStream):
         CBufferOutputStream(const shared_ptr[ResizableBuffer]& buffer)
 
-    cdef cppclass CMockOutputStream" arrow::io::MockOutputStream"\
-        (OutputStream):
+    cdef cppclass CMockOutputStream \
+            " arrow::io::MockOutputStream"(OutputStream):
         CMockOutputStream()
         int64_t GetExtentBytesWritten()
 
-    cdef cppclass CFixedSizeBufferWriter" arrow::io::FixedSizeBufferWriter"(WriteableFile):
+    cdef cppclass CFixedSizeBufferWriter \
+            " arrow::io::FixedSizeBufferWriter"(WriteableFile):
         CFixedSizeBufferWriter(const shared_ptr[CBuffer]& buffer)
 
 
@@ -609,48 +610,45 @@ cdef extern from "arrow/ipc/api.h" namespace "arrow::ipc" nogil:
 
     c_string FormatMessageType(MessageType type)
 
-    cdef cppclass CMessageReader \
-        " arrow::ipc::MessageReader":
+    cdef cppclass CMessageReader" arrow::ipc::MessageReader":
         CStatus ReadNextMessage(unique_ptr[CMessage]* out)
 
     cdef cppclass CInputStreamMessageReader \
-        " arrow::ipc::InputStreamMessageReader":
+            " arrow::ipc::InputStreamMessageReader":
         CInputStreamMessageReader(const shared_ptr[InputStream]& stream)
 
-    cdef cppclass CRecordBatchWriter \
-        " arrow::ipc::RecordBatchWriter":
+    cdef cppclass CRecordBatchWriter" arrow::ipc::RecordBatchWriter":
         CStatus Close()
         CStatus WriteRecordBatch(const CRecordBatch& batch)
 
-    cdef cppclass CRecordBatchReader \
-        " arrow::ipc::RecordBatchReader":
+    cdef cppclass CRecordBatchReader" arrow::ipc::RecordBatchReader":
         shared_ptr[CSchema] schema()
         CStatus ReadNextRecordBatch(shared_ptr[CRecordBatch]* batch)
 
     cdef cppclass CRecordBatchStreamReader \
-        " arrow::ipc::RecordBatchStreamReader"(CRecordBatchReader):
+            " arrow::ipc::RecordBatchStreamReader"(CRecordBatchReader):
         @staticmethod
         CStatus Open(const shared_ptr[InputStream]& stream,
                      shared_ptr[CRecordBatchStreamReader]* out)
 
         @staticmethod
         CStatus Open2" Open"(unique_ptr[CMessageReader] message_reader,
-                     shared_ptr[CRecordBatchStreamReader]* out)
+                             shared_ptr[CRecordBatchStreamReader]* out)
 
     cdef cppclass CRecordBatchStreamWriter \
-        " arrow::ipc::RecordBatchStreamWriter"(CRecordBatchWriter):
+            " arrow::ipc::RecordBatchStreamWriter"(CRecordBatchWriter):
         @staticmethod
         CStatus Open(OutputStream* sink, const shared_ptr[CSchema]& schema,
                      shared_ptr[CRecordBatchStreamWriter]* out)
 
     cdef cppclass CRecordBatchFileWriter \
-        " arrow::ipc::RecordBatchFileWriter"(CRecordBatchWriter):
+            " arrow::ipc::RecordBatchFileWriter"(CRecordBatchWriter):
         @staticmethod
         CStatus Open(OutputStream* sink, const shared_ptr[CSchema]& schema,
                      shared_ptr[CRecordBatchFileWriter]* out)
 
     cdef cppclass CRecordBatchFileReader \
-        " arrow::ipc::RecordBatchFileReader":
+            " arrow::ipc::RecordBatchFileReader":
         @staticmethod
         CStatus Open(const shared_ptr[RandomAccessFile]& file,
                      shared_ptr[CRecordBatchFileReader]* out)
@@ -724,7 +722,7 @@ cdef extern from "arrow/python/api.h" namespace "arrow::py" nogil:
     CStatus ConvertPySequence(object obj, CMemoryPool* pool,
                               shared_ptr[CArray]* out,
                               const shared_ptr[CDataType]& type,
-			      int64_t size)
+                              int64_t size)
 
     CStatus NumPyDtypeToArrow(object dtype, shared_ptr[CDataType]* type)
 
@@ -737,7 +735,7 @@ cdef extern from "arrow/python/api.h" namespace "arrow::py" nogil:
                                  shared_ptr[CChunkedArray]* out)
 
     CStatus NdarrayToTensor(CMemoryPool* pool, object ao,
-                            shared_ptr[CTensor]* out);
+                            shared_ptr[CTensor]* out)
 
     CStatus TensorToNdarray(const CTensor& tensor, object base,
                             PyObject** out)

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/io-hdfs.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/io-hdfs.pxi b/python/pyarrow/io-hdfs.pxi
index 8ac4e8c..27e9948 100644
--- a/python/pyarrow/io-hdfs.pxi
+++ b/python/pyarrow/io-hdfs.pxi
@@ -231,7 +231,6 @@ cdef class HadoopFileSystem:
             check_status(self.client.get()
                          .GetPathInfo(c_path, info))
 
-
     def ls(self, path, bint full_info):
         cdef:
             c_string c_path = tobytes(path)

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/io.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/io.pxi b/python/pyarrow/io.pxi
index 211c2a3..cccb173 100644
--- a/python/pyarrow/io.pxi
+++ b/python/pyarrow/io.pxi
@@ -255,13 +255,18 @@ cdef class NativeFile:
 
         if not hasattr(stream_or_path, 'read'):
             stream = open(stream_or_path, 'wb')
-            cleanup = lambda: stream.close()
+
+            def cleanup():
+                stream.close()
         else:
             stream = stream_or_path
-            cleanup = lambda: None
+
+            def cleanup():
+                pass
 
         done = False
         exc_info = None
+
         def bg_write():
             try:
                 while not done or write_queue.qsize() > 0:
@@ -326,6 +331,7 @@ cdef class NativeFile:
 
         done = False
         exc_info = None
+
         def bg_write():
             try:
                 while not done or write_queue.qsize() > 0:

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/ipc.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/ipc.pxi b/python/pyarrow/ipc.pxi
index 31ee578..d6f62aa 100644
--- a/python/pyarrow/ipc.pxi
+++ b/python/pyarrow/ipc.pxi
@@ -279,7 +279,7 @@ cdef class _RecordBatchFileWriter(_RecordBatchWriter):
         with nogil:
             check_status(
                 CRecordBatchFileWriter.Open(self.sink.get(), schema.sp_schema,
-                                      &writer))
+                                            &writer))
 
         # Cast to base class, because has same interface
         self.writer = <shared_ptr[CRecordBatchWriter]> writer

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/lib.pxd
----------------------------------------------------------------------
diff --git a/python/pyarrow/lib.pxd b/python/pyarrow/lib.pxd
index 3e1419b..48a58f7 100644
--- a/python/pyarrow/lib.pxd
+++ b/python/pyarrow/lib.pxd
@@ -17,6 +17,7 @@
 
 from pyarrow.includes.common cimport *
 from pyarrow.includes.libarrow cimport *
+from pyarrow.includes.libarrow cimport CStatus
 from cpython cimport PyObject
 from libcpp cimport nullptr
 
@@ -24,9 +25,6 @@ cdef extern from "Python.h":
     int PySlice_Check(object)
 
 
-from pyarrow.includes.libarrow cimport CStatus
-
-
 cdef int check_status(const CStatus& status) nogil except -1
 
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/lib.pyx
----------------------------------------------------------------------
diff --git a/python/pyarrow/lib.pyx b/python/pyarrow/lib.pyx
index 4df2fcd..789801b 100644
--- a/python/pyarrow/lib.pyx
+++ b/python/pyarrow/lib.pyx
@@ -19,31 +19,27 @@
 # distutils: language = c++
 # cython: embedsignature = True
 
-from cython.operator cimport dereference as deref
-from pyarrow.includes.libarrow cimport *
-from pyarrow.includes.common cimport PyObject_to_object
-cimport pyarrow.includes.libarrow as libarrow
-cimport cpython as cp
-
-
 import datetime
 import decimal as _pydecimal
+import multiprocessing
 import numpy as np
+import os
 import six
 from pyarrow.compat import frombytes, tobytes, PandasSeries, Categorical
 
+from cython.operator cimport dereference as deref
+from pyarrow.includes.libarrow cimport *
+from pyarrow.includes.common cimport PyObject_to_object
+cimport pyarrow.includes.libarrow as libarrow
+cimport cpython as cp
+
 cdef _pandas():
     import pandas as pd
     return pd
 
-
 arrow_init_numpy()
-
-import numpy as np
 set_numpy_nan(np.nan)
 
-import multiprocessing
-import os
 cdef int CPU_COUNT = int(
     os.environ.get('OMP_NUM_THREADS',
                    max(multiprocessing.cpu_count() // 2, 1)))
@@ -62,6 +58,7 @@ def cpu_count():
     """
     return CPU_COUNT
 
+
 def set_cpu_count(count):
     global CPU_COUNT
     CPU_COUNT = max(int(count), 1)
@@ -122,7 +119,5 @@ include "ipc.pxi"
 # Feather format
 include "feather.pxi"
 
-#----------------------------------------------------------------------
 # Public API
-
 include "public-api.pxi"

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/plasma.pyx
----------------------------------------------------------------------
diff --git a/python/pyarrow/plasma.pyx b/python/pyarrow/plasma.pyx
index dd62d47..befa283 100644
--- a/python/pyarrow/plasma.pyx
+++ b/python/pyarrow/plasma.pyx
@@ -60,8 +60,8 @@ cdef extern from "plasma/common.h":
         PLASMA_QUERY_LOCAL"plasma::PLASMA_QUERY_LOCAL",
         PLASMA_QUERY_ANYWHERE"plasma::PLASMA_QUERY_ANYWHERE"
 
-    cdef int ObjectStatusLocal"plasma::ObjectStatusLocal";
-    cdef int ObjectStatusRemote"plasma::ObjectStatusRemote";
+    cdef int ObjectStatusLocal"plasma::ObjectStatusLocal"
+    cdef int ObjectStatusRemote"plasma::ObjectStatusRemote"
 
 cdef extern from "plasma/client.h" nogil:
 
@@ -102,7 +102,7 @@ cdef extern from "plasma/client.h" nogil:
         CStatus Wait(int64_t num_object_requests,
                      CObjectRequest* object_requests,
                      int num_ready_objects, int64_t timeout_ms,
-                     int* num_objects_ready);
+                     int* num_objects_ready)
 
         CStatus Transfer(const char* addr, int port,
                          const CUniqueID& object_id)
@@ -312,9 +312,10 @@ cdef class PlasmaClient:
         result = []
         for i in range(object_buffers.size()):
             if object_buffers[i].data_size != -1:
-                result.append(self._make_plasma_buffer(
-                                  object_ids[i], object_buffers[i].data,
-                                  object_buffers[i].data_size))
+                result.append(
+                    self._make_plasma_buffer(object_ids[i],
+                                             object_buffers[i].data,
+                                             object_buffers[i].data_size))
             else:
                 result.append(None)
         return result
@@ -345,9 +346,10 @@ cdef class PlasmaClient:
         self._get_object_buffers(object_ids, timeout_ms, &object_buffers)
         result = []
         for i in range(object_buffers.size()):
-            result.append(self._make_plasma_buffer(
-                              object_ids[i], object_buffers[i].metadata,
-                              object_buffers[i].metadata_size))
+            result.append(
+                self._make_plasma_buffer(object_ids[i],
+                                         object_buffers[i].metadata,
+                                         object_buffers[i].metadata_size))
         return result
 
     def seal(self, ObjectID object_id):
@@ -502,7 +504,7 @@ cdef class PlasmaClient:
                                                 object_requests.data(),
                                                 num_returns, timeout,
                                                 &num_objects_ready))
-        cdef int num_to_return = min(num_objects_ready, num_returns);
+        cdef int num_to_return = min(num_objects_ready, num_returns)
         ready_ids = []
         waiting_ids = set(object_ids)
         cdef int num_returned = 0
@@ -510,7 +512,7 @@ cdef class PlasmaClient:
             if num_returned == num_to_return:
                 break
             if (object_requests[i].status == ObjectStatusLocal or
-                object_requests[i].status == ObjectStatusRemote):
+                    object_requests[i].status == ObjectStatusRemote):
                 ready_ids.append(
                     ObjectID(object_requests[i].object_id.binary()))
                 waiting_ids.discard(

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/public-api.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/public-api.pxi b/python/pyarrow/public-api.pxi
index 28e07ff..7e08f63 100644
--- a/python/pyarrow/public-api.pxi
+++ b/python/pyarrow/public-api.pxi
@@ -47,7 +47,8 @@ cdef public api bint pyarrow_is_data_type(object type_):
     return isinstance(type_, DataType)
 
 
-cdef public api shared_ptr[CDataType] pyarrow_unwrap_data_type(object data_type):
+cdef public api shared_ptr[CDataType] pyarrow_unwrap_data_type(
+        object data_type):
     cdef DataType type_
     if pyarrow_is_data_type(data_type):
         type_ = <DataType>(data_type)
@@ -57,7 +58,7 @@ cdef public api shared_ptr[CDataType] pyarrow_unwrap_data_type(object data_type)
 
 
 cdef public api object pyarrow_wrap_data_type(
-    const shared_ptr[CDataType]& type):
+        const shared_ptr[CDataType]& type):
     cdef:
         DataType out
 
@@ -149,7 +150,7 @@ cdef public api object pyarrow_wrap_array(const shared_ptr[CArray]&
sp_array):
 
 
 cdef public api object pyarrow_wrap_chunked_array(
-    const shared_ptr[CChunkedArray]& sp_array):
+        const shared_ptr[CChunkedArray]& sp_array):
     if sp_array.get() == NULL:
         raise ValueError('ChunkedArray was NULL')
 
@@ -177,7 +178,7 @@ cdef public api shared_ptr[CTensor] pyarrow_unwrap_tensor(object tensor):
 
 
 cdef public api object pyarrow_wrap_tensor(
-    const shared_ptr[CTensor]& sp_tensor):
+        const shared_ptr[CTensor]& sp_tensor):
     if sp_tensor.get() == NULL:
         raise ValueError('Tensor was NULL')
 
@@ -238,7 +239,7 @@ cdef public api shared_ptr[CRecordBatch] pyarrow_unwrap_batch(object batch):
 
 
 cdef public api object pyarrow_wrap_batch(
-    const shared_ptr[CRecordBatch]& cbatch):
+        const shared_ptr[CRecordBatch]& cbatch):
     cdef RecordBatch batch = RecordBatch()
     batch.init(cbatch)
     return batch

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/scalar.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/scalar.pxi b/python/pyarrow/scalar.pxi
index 1f72070..16d2bad 100644
--- a/python/pyarrow/scalar.pxi
+++ b/python/pyarrow/scalar.pxi
@@ -154,11 +154,11 @@ cdef class Time32Value(ArrayValue):
             CTime32Type* dtype = <CTime32Type*> ap.type().get()
 
         if dtype.unit() == TimeUnit_SECOND:
-            return (datetime.datetime(1970, 1, 1) +
-                    datetime.timedelta(seconds=ap.Value(self.index))).time()
+            delta = datetime.timedelta(seconds=ap.Value(self.index))
+            return (datetime.datetime(1970, 1, 1) + delta).time()
         else:
-            return (datetime.datetime(1970, 1, 1) +
-                    datetime.timedelta(milliseconds=ap.Value(self.index))).time()
+            delta = datetime.timedelta(milliseconds=ap.Value(self.index))
+            return (datetime.datetime(1970, 1, 1) + delta).time()
 
 
 cdef class Time64Value(ArrayValue):

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/table.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/table.pxi b/python/pyarrow/table.pxi
index 6277761..997b285 100644
--- a/python/pyarrow/table.pxi
+++ b/python/pyarrow/table.pxi
@@ -495,7 +495,6 @@ cdef class RecordBatch:
             entries.append((name, column))
         return OrderedDict(entries)
 
-
     def to_pandas(self, nthreads=None):
         """
         Convert the arrow::RecordBatch to a pandas DataFrame
@@ -585,7 +584,6 @@ def table_to_blocks(Table table, int nthreads):
     return PyObject_to_object(result_obj)
 
 
-
 cdef class Table:
     """
     A collection of top-level named, equal length Arrow arrays.
@@ -897,7 +895,8 @@ cdef class Table:
         """
         Number of rows in this table.
 
-        Due to the definition of a table, all columns have the same number of rows.
+        Due to the definition of a table, all columns have the same number of
+        rows.
 
         Returns
         -------

http://git-wip-us.apache.org/repos/asf/arrow/blob/e5ed31fc/python/pyarrow/types.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/types.pxi b/python/pyarrow/types.pxi
index ad2f336..592db4f 100644
--- a/python/pyarrow/types.pxi
+++ b/python/pyarrow/types.pxi
@@ -419,7 +419,7 @@ cdef DataType primitive_type(Type type):
     _type_cache[type] = out
     return out
 
-#------------------------------------------------------------
+# -----------------------------------------------------------
 # Type factory functions
 
 cdef int convert_metadata(dict metadata,


Mime
View raw message