Skip to content

Commit ca5cc0d

Browse files
No Authortexodus
authored andcommitted
Apply lint
Signed-off-by: Andrew Stein <steinlink@gmail.com>
1 parent e7d92ab commit ca5cc0d

File tree

18 files changed

+52
-326
lines changed

18 files changed

+52
-326
lines changed

docs/docs/development.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ pnpm run test
199199

200200
The JavaScript test suite is composed of two sections: a Node.js test, which
201201
asserts behavior of the `@finos/perspective` library, and a suite of
202-
[Playwright](https://playwright.dev/) tests, which
203-
assert the behavior of the rest of the UI facing packages.
202+
[Playwright](https://playwright.dev/) tests, which assert the behavior of the
203+
rest of the UI facing packages.
204204

205205
```bash
206206
pnpm run test --update-snapshots

rust/perspective-python/bench/tornado/server/new_api.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

1313
import multiprocessing
14-
import asyncio
1514
import os
1615
import os.path
1716
import time
1817
from perspective.core.globalpsp import shared_client
1918
from perspective.handlers.tornado import PerspectiveTornadoHandler
20-
from tornado.websocket import websocket_connect
2119
import tornado
2220
import threading
2321
import numpy

rust/perspective-python/perspective/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"PerspectiveWidget",
1818
"PerspectiveViewer",
1919
"PerspectiveTornadoHandler",
20+
"ProxySession",
2021
"Table",
2122
"View",
2223
]

rust/perspective-python/perspective/handlers/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

1313
try:
14-
from .aiohttp import PerspectiveAIOHTTPHandler
14+
from .aiohttp import PerspectiveAIOHTTPHandler # noqa: F401
1515
except ImportError:
1616
...
1717

1818
try:
19-
from .starlette import PerspectiveStarletteHandler
19+
from .starlette import PerspectiveStarletteHandler # noqa: F401
2020
except ImportError:
2121
...
2222

2323
try:
24-
from .tornado import PerspectiveTornadoHandler
24+
from .tornado import PerspectiveTornadoHandler # noqa: F401
2525
except ImportError:
2626
...

rust/perspective-python/perspective/tests/conftest.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,35 @@
2020
from faker import Faker
2121

2222

23-
fake = Faker()
24-
2523
# Our tests construct naive datetimes everywhere
2624
# so setting it here is an easy way to fix it globally.
2725
import os
26+
27+
# Perspective used to support datetime.date and datetime.datetime
28+
# as Table() constructor arguments, but now we forward the parameters
29+
# directly to JSON.loads. So to make sure the tests dont need to be
30+
# so utterly transmogrified, we have this little hack :)
31+
import json
32+
33+
2834
os.environ["TZ"] = "UTC"
2935

36+
37+
def new_encoder(self, obj):
38+
if isinstance(obj, datetime):
39+
return str(obj)
40+
elif isinstance(obj, date):
41+
return str(obj)
42+
else:
43+
return old(self, obj)
44+
45+
46+
old = json.JSONEncoder.default
47+
json.JSONEncoder.default = new_encoder
48+
49+
fake = Faker()
50+
51+
3052
def _make_date_time_index(size, time_unit):
3153
return pd.date_range("2000-01-01", periods=size, freq=time_unit)
3254

@@ -248,21 +270,3 @@ def superstore(count=100):
248270
dat["Profit"] = round(random() * 1000, 2)
249271
data.append(dat)
250272
return pd.DataFrame(data)
251-
252-
253-
# Perspective used to support datetime.date and datetime.datetime
254-
# as Table() constructor arguments, but now we forward the parameters
255-
# directly to JSON.loads. So to make sure the tests dont need to be
256-
# so utterly transmogrified, we have this little hack :)
257-
import json
258-
old = json.JSONEncoder.default
259-
260-
def new_encoder(self, obj):
261-
if isinstance(obj, datetime):
262-
return str(obj)
263-
elif isinstance(obj, date):
264-
return str(obj)
265-
else:
266-
return old(self, obj)
267-
268-
json.JSONEncoder.default = new_encoder

rust/perspective-python/perspective/tests/core/test_async.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Server,
2121
Client,
2222
)
23-
from pytest import mark, raises
23+
from pytest import mark
2424

2525

2626
def syncify(f):
@@ -119,29 +119,6 @@ def _task():
119119
assert _task() == 10
120120
tbl.delete()
121121

122-
@mark.skip(reason="We take a loop to construct the client now")
123-
def test_async_call_loop_error_if_no_loop(self):
124-
server = Server()
125-
client = Client.from_server(
126-
server, lambda fn, *args: TestAsync.loop.add_callback(fn, *args)
127-
)
128-
tbl = client.table({"a": "integer", "b": "float", "c": "string"})
129-
130-
with raises(PerspectiveError):
131-
# loop not set - errors
132-
tbl.update(data)
133-
134-
tbl.update(data)
135-
136-
@syncify
137-
def _task():
138-
return tbl.size()
139-
140-
# subsequent calls to call_loop will work if loop_callback is set.
141-
assert _task() == 10
142-
143-
tbl.delete()
144-
145122
def test_async_multiple_managers_queue_process(self):
146123
server = Server()
147124
client = Client.from_server(

rust/perspective-python/perspective/tests/server/test_server.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def validate_post(self, msg, expected=None):
3939
def test_server_host_table(self):
4040
server = Server()
4141
client = Client.from_server(server)
42-
table = client.table(data, name="table1")
42+
client.table(data, name="table1")
4343
table2 = client.open_table("table1")
4444
assert table2.schema() == {"a": "integer", "b": "string"}
4545

@@ -126,15 +126,11 @@ def test_locked_client_create_view(self):
126126
assert client._get_view("view1").schema() == {"a": "integer", "b": "string"}
127127

128128
def test_server_create_view_zero(self):
129-
message = {"id": 1, "table_name": "table1", "view_name": "view1", "cmd": "view"}
130129
server = Server()
131130
client = Client.from_server(server)
132131
client.table(data, name="table1")
133132
table = client.open_table("table1")
134-
print(f"XXX: {dir(table)}")
135133
assert table.view().dimensions()["num_view_rows"] == 3
136-
# client._process(message, self.post)
137-
# assert client._views["view1"].num_rows() == 3
138134

139135
def test_server_create_view_one(self):
140136
server = Server()

rust/perspective-python/perspective/tests/table/test_table.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
# ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
1111
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
1212

13-
import sys
14-
from datetime import date, datetime, timezone
13+
from datetime import date, datetime
1514
import perspective
16-
from pytest import mark, raises, skip
15+
from pytest import mark, raises
1716
import pytest
1817
import perspective as psp
1918

@@ -446,7 +445,10 @@ def test_table_index_date_with_none(self):
446445
},
447446
index="a",
448447
)
449-
ts = lambda x: int(datetime.timestamp(x) * 1000)
448+
449+
def ts(x):
450+
return int(datetime.timestamp(x) * 1000)
451+
450452
assert tbl.view().to_columns() == {
451453
"a": [
452454
None,

rust/perspective-python/perspective/tests/table/test_table_datetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def test_table_datetime_min_epoch(self, util):
216216
def test_table_datetime_cant_convert_from_int(self):
217217
data = pd.DataFrame({"a": [0]})
218218
table = Table({"a": "datetime"})
219-
with raises(PerspectiveError) as ex:
219+
with raises(PerspectiveError):
220220
table.update(data)
221221
# assert str(ex.value) == "..."
222222

rust/perspective-python/perspective/tests/table/test_table_infer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_table_bool_infer_str_all_formats_from_schema(self):
5858
"b": [False, False, False, False, False],
5959
}
6060

61-
def test_table_infer_bool(self):
61+
def test_table_infer_bool_variant(self):
6262
data = {"a": [None, None, None, None, True, True, True]}
6363
tbl = Table(data)
6464
assert tbl.schema() == {"a": "boolean"}

0 commit comments

Comments
 (0)