Skip to content

Commit 2670e9a

Browse files
committed
ADD: Add docformatter to pre-commit
1 parent 0ca7277 commit 2670e9a

29 files changed

+297
-239
lines changed

databento/common/bentologging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
def enable_logging(level: int | str = logging.INFO) -> None:
77
"""
8-
Enable logging for the Databento module.
9-
This function should be used for simple applications and examples.
10-
It is advisible to configure your own logging for serious applications.
8+
Enable logging for the Databento module. This function should be used for
9+
simple applications and examples. It is advisible to configure your own
10+
logging for serious applications.
1111
1212
Parameters
1313
----------

databento/common/cram.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
"""Functions for handling challenge-response authentication"""
1+
"""
2+
Functions for handling challenge-response authentication.
3+
"""
24
import argparse
35
import hashlib
46
import os
@@ -10,9 +12,8 @@
1012

1113
def get_challenge_response(challenge: str, key: str) -> str:
1214
"""
13-
Return the response for a given challenge-response
14-
authentication mechanism (CRAM) code provided by
15-
a Databento service.
15+
Return the response for a given challenge-response authentication mechanism
16+
(CRAM) code provided by a Databento service.
1617
1718
A valid API key is hashed with the challenge string.
1819

databento/common/dbnstore.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555

5656
def is_zstandard(reader: IO[bytes]) -> bool:
5757
"""
58-
Determine if an `IO[bytes]` reader contains zstandard compressed
59-
data.
58+
Determine if an `IO[bytes]` reader contains zstandard compressed data.
6059
6160
Parameters
6261
----------
@@ -96,7 +95,9 @@ def is_dbn(reader: IO[bytes]) -> bool:
9695

9796

9897
class DataSource(abc.ABC):
99-
"""Abstract base class for backing DBNStore instances with data."""
98+
"""
99+
Abstract base class for backing DBNStore instances with data.
100+
"""
100101

101102
def __init__(self, source: object) -> None:
102103
...
@@ -244,8 +245,8 @@ def nbytes(self) -> int:
244245
@property
245246
def reader(self) -> IO[bytes]:
246247
"""
247-
Return a reader for this buffer.
248-
The reader beings at the start of the buffer.
248+
Return a reader for this buffer. The reader beings at the start of the
249+
buffer.
249250
250251
Returns
251252
-------
@@ -500,8 +501,8 @@ def _map_symbols(self, df: pd.DataFrame, pretty_ts: bool) -> pd.DataFrame:
500501
@property
501502
def compression(self) -> Compression:
502503
"""
503-
Return the data compression format (if any).
504-
This is determined by inspecting the data.
504+
Return the data compression format (if any). This is determined by
505+
inspecting the data.
505506
506507
Returns
507508
-------
@@ -525,8 +526,8 @@ def dataset(self) -> str:
525526
@property
526527
def end(self) -> pd.Timestamp | None:
527528
"""
528-
Return the query end for the data.
529-
If None, the end time was not known when the data was generated.
529+
Return the query end for the data. If None, the end time was not known
530+
when the data was generated.
530531
531532
Returns
532533
-------
@@ -632,8 +633,7 @@ def reader(self) -> IO[bytes]:
632633
@property
633634
def schema(self) -> Schema | None:
634635
"""
635-
Return the DBN record schema.
636-
If None, may contain one or more schemas.
636+
Return the DBN record schema. If None, may contain one or more schemas.
637637
638638
Returns
639639
-------
@@ -664,8 +664,8 @@ def start(self) -> pd.Timestamp:
664664
@property
665665
def stype_in(self) -> SType | None:
666666
"""
667-
Return the query input symbology type for the data.
668-
If None, the records may contain mixed STypes.
667+
Return the query input symbology type for the data. If None, the
668+
records may contain mixed STypes.
669669
670670
Returns
671671
-------

databento/common/enums.py

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323

2424
def coercible(enum_type: type[M]) -> type[M]:
25-
"""Decorate coercible enumerations.
25+
"""
26+
Decorate coercible enumerations.
2627
2728
Decorating an Enum class with this function will intercept calls to
2829
__new__ and perform a type coercion for the passed value. The type conversion
@@ -94,13 +95,12 @@ def coerced_new(enum: type[M], value: object) -> M:
9495

9596
class StringyMixin:
9697
"""
97-
Mixin class for overloading __str__ on Enum types.
98-
This will use the Enumerations subclass, if any, to modify
99-
the behavior of str().
98+
Mixin class for overloading __str__ on Enum types. This will use the
99+
Enumerations subclass, if any, to modify the behavior of str().
100100
101-
For subclasses of enum.Flag a comma separated string of names is returned.
102-
For integer enumerations, the lowercase member name is returned.
103-
For string enumerations, the value is returned.
101+
For subclasses of enum.Flag a comma separated string of names is
102+
returned. For integer enumerations, the lowercase member name is
103+
returned. For string enumerations, the value is returned.
104104
105105
"""
106106

@@ -115,15 +115,19 @@ def __str__(self) -> str:
115115
@unique
116116
@coercible
117117
class HistoricalGateway(StringyMixin, str, Enum):
118-
"""Represents a historical data center gateway location."""
118+
"""
119+
Represents a historical data center gateway location.
120+
"""
119121

120122
BO1 = "https://hist.databento.com"
121123

122124

123125
@unique
124126
@coercible
125127
class FeedMode(StringyMixin, str, Enum):
126-
"""Represents a data feed mode."""
128+
"""
129+
Represents a data feed mode.
130+
"""
127131

128132
HISTORICAL = "historical"
129133
HISTORICAL_STREAMING = "historical-streaming"
@@ -133,7 +137,9 @@ class FeedMode(StringyMixin, str, Enum):
133137
@unique
134138
@coercible
135139
class Dataset(StringyMixin, str, Enum):
136-
"""Represents a dataset code (string identifier)."""
140+
"""
141+
Represents a dataset code (string identifier).
142+
"""
137143

138144
GLBX_MDP3 = "GLBX.MDP3"
139145
XNAS_ITCH = "XNAS.ITCH"
@@ -142,7 +148,9 @@ class Dataset(StringyMixin, str, Enum):
142148
@unique
143149
@coercible
144150
class Schema(StringyMixin, str, Enum):
145-
"""Represents a data record schema."""
151+
"""
152+
Represents a data record schema.
153+
"""
146154

147155
MBO = "mbo"
148156
MBP_1 = "mbp-1"
@@ -188,7 +196,9 @@ def get_record_type(self) -> type[DBNRecord]:
188196
@unique
189197
@coercible
190198
class Encoding(StringyMixin, str, Enum):
191-
"""Represents a data output encoding."""
199+
"""
200+
Represents a data output encoding.
201+
"""
192202

193203
DBN = "dbn"
194204
CSV = "csv"
@@ -198,7 +208,9 @@ class Encoding(StringyMixin, str, Enum):
198208
@unique
199209
@coercible
200210
class Compression(StringyMixin, str, Enum):
201-
"""Represents a data compression format (if any)."""
211+
"""
212+
Represents a data compression format (if any).
213+
"""
202214

203215
NONE = "none"
204216
ZSTD = "zstd"
@@ -207,7 +219,9 @@ class Compression(StringyMixin, str, Enum):
207219
@unique
208220
@coercible
209221
class SplitDuration(StringyMixin, str, Enum):
210-
"""Represents the duration before splitting for each batched data file."""
222+
"""
223+
Represents the duration before splitting for each batched data file.
224+
"""
211225

212226
DAY = "day"
213227
WEEK = "week"
@@ -218,7 +232,9 @@ class SplitDuration(StringyMixin, str, Enum):
218232
@unique
219233
@coercible
220234
class Packaging(StringyMixin, str, Enum):
221-
"""Represents the packaging method for batched data files."""
235+
"""
236+
Represents the packaging method for batched data files.
237+
"""
222238

223239
NONE = "none"
224240
ZIP = "zip"
@@ -228,7 +244,9 @@ class Packaging(StringyMixin, str, Enum):
228244
@unique
229245
@coercible
230246
class Delivery(StringyMixin, str, Enum):
231-
"""Represents the delivery mechanism for batched data."""
247+
"""
248+
Represents the delivery mechanism for batched data.
249+
"""
232250

233251
DOWNLOAD = "download"
234252
S3 = "s3"
@@ -238,7 +256,9 @@ class Delivery(StringyMixin, str, Enum):
238256
@unique
239257
@coercible
240258
class SType(StringyMixin, str, Enum):
241-
"""Represents a symbology type."""
259+
"""
260+
Represents a symbology type.
261+
"""
242262

243263
INSTRUMENT_ID = "instrument_id"
244264
RAW_SYMBOL = "raw_symbol"
@@ -249,7 +269,9 @@ class SType(StringyMixin, str, Enum):
249269
@unique
250270
@coercible
251271
class RollRule(StringyMixin, str, Enum):
252-
"""Represents a smart symbology roll rule."""
272+
"""
273+
Represents a smart symbology roll rule.
274+
"""
253275

254276
VOLUME = "volume"
255277
OPEN_INTEREST = "open_interst"
@@ -265,6 +287,7 @@ class SymbologyResolution(StringyMixin, str, Enum):
265287
- OK: All symbol mappings resolved.
266288
- PARTIAL: One or more symbols did not resolve on at least one date.
267289
- NOT_FOUND: One or more symbols where not found on any date in range.
290+
268291
"""
269292

270293
OK = "ok"
@@ -276,7 +299,8 @@ class SymbologyResolution(StringyMixin, str, Enum):
276299
@coercible
277300
# Ignore type to work around mypy bug https://github.com/python/mypy/issues/9319
278301
class RecordFlags(StringyMixin, IntFlag): # type: ignore
279-
"""Represents record flags.
302+
"""
303+
Represents record flags.
280304
281305
F_LAST
282306
Last message in the packet from the venue for a given `instrument_id`.
@@ -288,6 +312,7 @@ class RecordFlags(StringyMixin, IntFlag): # type: ignore
288312
The `ts_recv` value is inaccurate (clock issues or reordering).
289313
290314
Other bits are reserved and have no current meaning.
315+
291316
"""
292317

293318
F_LAST = 128

databento/common/parsing.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def optional_symbols_list_to_string(
9090
@optional_symbols_list_to_string.register
9191
def _(_: None, __: SType) -> str:
9292
"""
93-
Dispatch method for optional_symbols_list_to_string.
94-
Handles None which defaults to ALL_SYMBOLS.
93+
Dispatch method for optional_symbols_list_to_string. Handles None which
94+
defaults to ALL_SYMBOLS.
9595
9696
See Also
9797
--------
@@ -104,9 +104,8 @@ def _(_: None, __: SType) -> str:
104104
@optional_symbols_list_to_string.register
105105
def _(symbols: Number, stype_in: SType) -> str:
106106
"""
107-
Dispatch method for optional_symbols_list_to_string.
108-
Handles numerical types, alerting when an integer is
109-
given for STypes that expect strings.
107+
Dispatch method for optional_symbols_list_to_string. Handles numerical
108+
types, alerting when an integer is given for STypes that expect strings.
110109
111110
See Also
112111
--------
@@ -124,8 +123,8 @@ def _(symbols: Number, stype_in: SType) -> str:
124123
@optional_symbols_list_to_string.register
125124
def _(symbols: str, stype_in: SType) -> str:
126125
"""
127-
Dispatch method for optional_symbols_list_to_string.
128-
Handles str, splitting on commas and validating smart symbology.
126+
Dispatch method for optional_symbols_list_to_string. Handles str, splitting
127+
on commas and validating smart symbology.
129128
130129
See Also
131130
--------
@@ -154,8 +153,8 @@ def _(symbols: str, stype_in: SType) -> str:
154153
@optional_symbols_list_to_string.register(cls=Iterable)
155154
def _(symbols: Iterable[str] | Iterable[int], stype_in: SType) -> str:
156155
"""
157-
Dispatch method for optional_symbols_list_to_string.
158-
Handles Iterables by dispatching the individual members.
156+
Dispatch method for optional_symbols_list_to_string. Handles Iterables by
157+
dispatching the individual members.
159158
160159
See Also
161160
--------
@@ -295,7 +294,8 @@ def optional_datetime_to_unix_nanoseconds(
295294
value: pd.Timestamp | str | int | None,
296295
) -> int | None:
297296
"""
298-
Return a valid UNIX nanosecond timestamp from the given value (if not None).
297+
Return a valid UNIX nanosecond timestamp from the given value (if not
298+
None).
299299
300300
Parameters
301301
----------

databento/common/symbology.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class InstrumentIdMappingInterval:
2121
The raw symbol value.
2222
instrument_id : int
2323
The instrument ID value.
24+
2425
"""
2526

2627
start_date: dt.date

databento/common/validation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def validate_enum(
4343
param: str,
4444
) -> E:
4545
"""
46-
Validate whether the given value is either the correct Enum type, or a valid
47-
value of that enum.
46+
Validate whether the given value is either the correct Enum type, or a
47+
valid value of that enum.
4848
4949
Parameters
5050
----------
@@ -147,6 +147,7 @@ def validate_gateway(
147147
def validate_semantic_string(value: str, param: str) -> str:
148148
"""
149149
Validate whether a string contains a semantic value.
150+
150151
A string is considered absent of meaning if:
151152
- It is empty.
152153
- It contains only whitespace.

databento/historical/api/metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ def get_cost(
421421
limit: int | None = None,
422422
) -> float:
423423
"""
424-
Request the cost in US dollars for historical streaming or batched files
425-
from Databento.
424+
Request the cost in US dollars for historical streaming or batched
425+
files from Databento.
426426
427427
Makes a `GET /metadata.get_cost` HTTP request.
428428

databento/historical/api/timeseries.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ async def get_range_async(
135135
path: PathLike[str] | str | None = None,
136136
) -> DBNStore:
137137
"""
138-
Asynchronously request a historical time series data stream from Databento.
138+
Asynchronously request a historical time series data stream from
139+
Databento.
139140
140141
Makes a `GET /timeseries.get_range` HTTP request.
141142

databento/historical/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Historical:
3232
--------
3333
> import databento as db
3434
> client = db.Historical('YOUR_API_KEY')
35+
3536
"""
3637

3738
def __init__(

0 commit comments

Comments
 (0)