Skip to content

Commit 5304537

Browse files
authored
ARROW-154 Add blacken-docs to pre-commit hook (#133)
1 parent 722df95 commit 5304537

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,10 @@ repos:
6161
files: ^\.github/workflows/
6262
types: [yaml]
6363
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]
64+
65+
- repo: https://github.com/adamchainz/blacken-docs
66+
rev: "1.13.0"
67+
hooks:
68+
- id: blacken-docs
69+
additional_dependencies:
70+
- black==22.3.0

bindings/python/README.rst

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,32 @@ PyMongoArrow
1212
for loading MongoDB query result sets as Apache Arrow tables, Pandas
1313
DataFrames or NumPy arrays.
1414

15-
.. code-block:: python
15+
.. code-block:: pycon
1616
1717
>>> from pymongoarrow.monkey import patch_all
18-
>>> patch_all()
19-
>>> from pymongoarrow.api import Schema
20-
>>> schema = Schema({'_id': int, 'qty': float})
21-
>>> from pymongo import MongoClient
22-
>>> client = MongoClient()
23-
>>> client.db.data.insert_many([{'_id': 1, 'qty': 25.4}, {'_id': 2, 'qty': 16.9}, {'_id': 3, 'qty': 2.3}])
24-
>>> data_frame = client.db.test.find_pandas_all({}, schema=schema)
25-
>>> data_frame
18+
... patch_all()
19+
... from pymongoarrow.api import Schema
20+
... schema = Schema({"_id": int, "qty": float})
21+
... from pymongo import MongoClient
22+
... client = MongoClient()
23+
... client.db.data.insert_many(
24+
... [{"_id": 1, "qty": 25.4}, {"_id": 2, "qty": 16.9}, {"_id": 3, "qty": 2.3}]
25+
... )
26+
... data_frame = client.db.test.find_pandas_all({}, schema=schema)
27+
... data_frame
2628
_id qty
2729
0 1 25.4
2830
1 2 16.9
2931
2 3 2.3
30-
>>> arrow_table = client.db.test.find_arrow_all({}, schema=schema)
32+
... arrow_table = client.db.test.find_arrow_all({}, schema=schema)
3133
# The schema may also be omitted
32-
>>> arrow_table = client.db.test.find_arrow_all({})
33-
>>> arrow_table
34+
... arrow_table = client.db.test.find_arrow_all({})
35+
... arrow_table
3436
pyarrow.Table
3537
_id: int64
3638
qty: double
37-
>>> ndarrays = client.db.test.find_numpy_all({}, schema=schema)
38-
>>> ndarrays
39+
... ndarrays = client.db.test.find_numpy_all({}, schema=schema)
40+
... ndarrays
3941
{'_id': array([1, 2, 3]), 'qty': array([25.4, 16.9, 2.3])}
4042
4143
**PyMongoArrow** is the recommended way to

0 commit comments

Comments
 (0)