Skip to content

Commit 81f38e0

Browse files
committed
ADD: Add public repos to ruff pre-commit coverage
1 parent 019804f commit 81f38e0

32 files changed

+519
-525
lines changed

databento/common/bentologging.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from __future__ import annotations
2+
13
import logging
2-
from typing import Union
34

45

5-
def enable_logging(level: Union[int, str] = logging.INFO) -> None:
6+
def enable_logging(level: int | str = logging.INFO) -> None:
67
"""
78
Enable logging for the Databento module.
89
This function should be used for simple applications and examples.

databento/common/cram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_challenge_response(challenge: str, key: str) -> str:
2929
3030
"""
3131
bucket_id = key[-BUCKET_ID_LENGTH:]
32-
sha = hashlib.sha256(f"{challenge}|{key}".encode("utf-8")).hexdigest()
32+
sha = hashlib.sha256(f"{challenge}|{key}".encode()).hexdigest()
3333
return f"{sha}-{bucket_id}"
3434

3535

databento/common/data.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Dict, List, Tuple, Union
1+
from __future__ import annotations
22

33
import numpy as np
44

@@ -10,7 +10,7 @@
1010
################################################################################
1111

1212

13-
def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
13+
def get_deriv_ba_types(level: int) -> list[tuple[str, type | str]]:
1414
return [
1515
(f"bid_px_{level:02d}", np.int64),
1616
(f"ask_px_{level:02d}", np.int64),
@@ -37,15 +37,15 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
3737
)
3838

3939

40-
RECORD_HEADER: List[Tuple[str, Union[type, str]]] = [
40+
RECORD_HEADER: list[tuple[str, type | str]] = [
4141
("length", np.uint8),
4242
("rtype", np.uint8),
4343
("publisher_id", np.uint16),
4444
("instrument_id", np.uint32),
4545
("ts_event", np.uint64),
4646
]
4747

48-
MBO_MSG: List[Tuple[str, Union[type, str]]] = RECORD_HEADER + [
48+
MBO_MSG: list[tuple[str, type | str]] = RECORD_HEADER + [
4949
("order_id", np.uint64),
5050
("price", np.int64),
5151
("size", np.uint32),
@@ -58,7 +58,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
5858
("sequence", np.uint32),
5959
]
6060

61-
MBP_MSG: List[Tuple[str, Union[type, str]]] = RECORD_HEADER + [
61+
MBP_MSG: list[tuple[str, type | str]] = RECORD_HEADER + [
6262
("price", np.int64),
6363
("size", np.uint32),
6464
("action", "S1"), # 1 byte chararray
@@ -71,15 +71,15 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
7171
]
7272

7373

74-
OHLCV_MSG: List[Tuple[str, Union[type, str]]] = RECORD_HEADER + [
74+
OHLCV_MSG: list[tuple[str, type | str]] = RECORD_HEADER + [
7575
("open", np.int64),
7676
("high", np.int64),
7777
("low", np.int64),
7878
("close", np.int64),
7979
("volume", np.int64),
8080
]
8181

82-
DEFINITION_MSG: List[Tuple[str, Union[type, str]]] = RECORD_HEADER + [
82+
DEFINITION_MSG: list[tuple[str, type | str]] = RECORD_HEADER + [
8383
("ts_recv", np.uint64),
8484
("min_price_increment", np.int64),
8585
("display_factor", np.int64),
@@ -147,7 +147,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
147147
("dummy", "S3"), # 3 byte chararray (Adjustment filler for 8-bytes alignment)
148148
]
149149

150-
IMBALANCE_MSG: List[Tuple[str, Union[type, str]]] = RECORD_HEADER + [
150+
IMBALANCE_MSG: list[tuple[str, type | str]] = RECORD_HEADER + [
151151
("ts_recv", np.uint64),
152152
("ref_price", np.int64),
153153
("auction_time", np.uint64),
@@ -171,7 +171,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
171171
("dummy", "S1"),
172172
]
173173

174-
STATISTICS_MSG: List[Tuple[str, Union[type, str]]] = RECORD_HEADER + [
174+
STATISTICS_MSG: list[tuple[str, type | str]] = RECORD_HEADER + [
175175
("ts_recv", np.uint64),
176176
("ts_ref", np.uint64),
177177
("price", np.int64),
@@ -186,7 +186,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
186186
]
187187

188188

189-
STRUCT_MAP: Dict[Schema, List[Tuple[str, Union[type, str]]]] = {
189+
STRUCT_MAP: dict[Schema, list[tuple[str, type | str]]] = {
190190
Schema.MBO: MBO_MSG,
191191
Schema.MBP_1: MBP_MSG + get_deriv_ba_types(0), # 1
192192
Schema.MBP_10: MBP_MSG
@@ -253,7 +253,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
253253
################################################################################
254254

255255

256-
def get_deriv_ba_fields(level: int) -> List[str]:
256+
def get_deriv_ba_fields(level: int) -> list[str]:
257257
return [
258258
f"bid_px_{level:02d}",
259259
f"ask_px_{level:02d}",

0 commit comments

Comments
 (0)