Skip to content

Commit 4d15d67

Browse files
committed
Lint: Add Async and Bandit rules
1 parent 183d2a5 commit 4d15d67

File tree

7 files changed

+31
-16
lines changed

7 files changed

+31
-16
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
- uses: actions/checkout@v4
2020
- uses: astral-sh/setup-uv@v6
2121
- run: uv python install ${{ matrix.python }}
22-
- run: uv run ruff check src/obelisk/
23-
- run: uv run ruff format --check src/obelisk/
22+
- run: uv run ruff check
23+
- run: uv run ruff format
2424
- run: uv run mypy
2525
test:
2626
name: Run tests

hooks/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
# Redirect output to stderr.
1111
exec 1>&2
1212

13-
uv run ruff format --check src/obelisk/
13+
uv run ruff format --check
1414
uv run mypy

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,10 @@ packages = ["src/obelisk"]
5454
[tool.mypy]
5555
files = "src/obelisk"
5656
strict = true
57+
58+
[tool.ruff]
59+
include = ["src/obelisk/**/*.py"]
60+
61+
[tool.ruff.lint]
62+
select = ["E4", "E7", "E9", "F", "ASYNC", "S"]
63+
ignore = []

src/tests/asynchronous/client_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
client_id = "682c6c46604b3b3be35429df"
66
client_secret = "7136832d-01be-456a-a1fe-25c7f9e130c5"
77

8-
pytest_plugins = ('pytest_asyncio',)
8+
pytest_plugins = ("pytest_asyncio",)
9+
910

1011
@pytest.mark.asyncio
1112
async def test_fetch_demo_igent():
@@ -15,7 +16,7 @@ async def test_fetch_demo_igent():
1516
metrics=["org.dyamand.types.common.Temperature::number"],
1617
from_timestamp=1740924034000,
1718
to_timestamp=1741100614258,
18-
limit=2
19+
limit=2,
1920
)
2021

2122
assert len(result.items) == 2
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from obelisk.asynchronous.core import QueryParams
22

3+
34
def test_query_param_serialize():
4-
q = QueryParams(dataset="83989232", filter_="(metric=='smartphone.application::string')", dataType='string')
5+
q = QueryParams(
6+
dataset="83989232",
7+
filter_="(metric=='smartphone.application::string')",
8+
dataType="string",
9+
)
510
dump = q.to_dict()
611
assert "filter" in dump

src/tests/sync/client_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
client_id = "682c6c46604b3b3be35429df"
44
client_secret = "7136832d-01be-456a-a1fe-25c7f9e130c5"
55

6+
67
def test_demo_igent_fetch():
78
consumer = Obelisk(client=client_id, secret=client_secret)
89
result = consumer.fetch_single_chunk(
910
datasets=["612f6c39cbceda0ea9753d95"],
1011
metrics=["org.dyamand.types.common.Temperature::number"],
1112
from_timestamp=1740924034000,
1213
to_timestamp=1741100614258,
13-
limit=2
14+
limit=2,
1415
)
1516

1617
assert len(result.items) == 2
1718

19+
1820
def test_two_instances():
1921
consumer_one = Obelisk(client=client_id, secret=client_secret)
2022
consumer_two = Obelisk(client=client_id, secret=client_secret)
@@ -23,14 +25,14 @@ def test_two_instances():
2325
metrics=["org.dyamand.types.common.Temperature::number"],
2426
from_timestamp=1740924034000,
2527
to_timestamp=1741100614258,
26-
limit=2
28+
limit=2,
2729
)
2830
result_two = consumer_two.fetch_single_chunk(
2931
datasets=["612f6c39cbceda0ea9753d95"],
3032
metrics=["org.dyamand.types.common.Temperature::number"],
3133
from_timestamp=1740924034000,
3234
to_timestamp=1741100614258,
33-
limit=2
35+
limit=2,
3436
)
3537
assert len(result_one.items) == 2
3638
assert len(result_two.items) == 2

src/tests/typetest/filter_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
def test_basic_filter():
66
test_dt = datetime.now()
7-
f = Filter() \
7+
f = (
8+
Filter()
89
.add_and(
9-
Comparison.equal('source', 'test source'),
10-
)\
11-
.add_or(
12-
Comparison.less('timestamp', test_dt)
13-
)\
10+
Comparison.equal("source", "test source"),
11+
)
12+
.add_or(Comparison.less("timestamp", test_dt))
1413
.add_or(
15-
Comparison.is_in('metricType', ['number', 'number[]']),
14+
Comparison.is_in("metricType", ["number", "number[]"]),
1615
)
16+
)
1717

1818
expected = f"((('source'=='test source'),'timestamp'<'{test_dt.isoformat()}'),'metricType'=in=('number', 'number[]'))"
1919
assert str(f) == expected

0 commit comments

Comments
 (0)