bitvavo-api-upgraded 1.15.8__py3-none-any.whl → 1.16.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,21 @@
1
1
  """
2
2
  Some helper functions that should make my life a lot easier
3
3
  """
4
+
4
5
  from logging.config import dictConfig
5
6
  from time import time
7
+ from typing import TYPE_CHECKING
6
8
 
7
9
  import structlog
8
10
 
9
11
  from bitvavo_api_upgraded.settings import BITVAVO_API_UPGRADED
10
12
  from bitvavo_api_upgraded.type_aliases import ms, s_f
11
13
 
14
+ if TYPE_CHECKING:
15
+ from collections.abc import Callable
16
+
17
+ from structlog.types import EventDict, WrappedLogger
18
+
12
19
 
13
20
  def time_ms() -> ms:
14
21
  return int(time() * 1000)
@@ -19,15 +26,14 @@ def time_to_wait(rateLimitResetAt: ms) -> s_f:
19
26
  if curr_time > rateLimitResetAt:
20
27
  # rateLimitRemaining has already reset
21
28
  return 0.0
22
- else:
23
- return abs(s_f((rateLimitResetAt - curr_time) / 1000))
29
+ return abs(s_f((rateLimitResetAt - curr_time) / 1000))
24
30
 
25
31
 
26
32
  def configure_loggers() -> None:
27
33
  """
28
34
  source: https://docs.python.org/3.9/library/logging.config.html#dictionary-schema-details
29
35
  """
30
- shared_pre_chain = [
36
+ shared_pre_chain: list[Callable[[WrappedLogger, str, EventDict], EventDict]] = [
31
37
  structlog.threadlocal.merge_threadlocal,
32
38
  structlog.stdlib.add_logger_name, # show which named logger made the message!
33
39
  structlog.processors.add_log_level, # info, warning, error, etc
@@ -72,7 +78,7 @@ def configure_loggers() -> None:
72
78
  "propagate": True,
73
79
  },
74
80
  },
75
- }
81
+ },
76
82
  )
77
83
 
78
84
  structlog.configure(
File without changes
@@ -1,7 +1,7 @@
1
1
  import logging
2
-
3
2
  from pathlib import Path
4
- from decouple import Choices, AutoConfig
3
+
4
+ from decouple import AutoConfig, Choices
5
5
 
6
6
  from bitvavo_api_upgraded.type_aliases import ms
7
7
 
@@ -13,10 +13,14 @@ config = AutoConfig(search_path=Path.cwd())
13
13
  class _BitvavoApiUpgraded:
14
14
  # default LOG_LEVEL is WARNING, so users don't get their ass spammed.
15
15
  LOG_LEVEL: str = config(
16
- "BITVAVO_API_UPGRADED_LOG_LEVEL", default="INFO", cast=Choices(list(logging._nameToLevel.keys()))
16
+ "BITVAVO_API_UPGRADED_LOG_LEVEL",
17
+ default="INFO",
18
+ cast=Choices(list(logging._nameToLevel.keys())), # noqa: SLF001
17
19
  )
18
20
  LOG_EXTERNAL_LEVEL: str = config(
19
- "BITVAVO_API_UPGRADED_EXTERNAL_LOG_LEVEL", default="WARNING", cast=Choices(list(logging._nameToLevel.keys()))
21
+ "BITVAVO_API_UPGRADED_EXTERNAL_LOG_LEVEL",
22
+ default="WARNING",
23
+ cast=Choices(list(logging._nameToLevel.keys())), # noqa: SLF001
20
24
  )
21
25
  LAG: ms = config("BITVAVO_API_UPGRADED_LAG", default=ms(50), cast=ms)
22
26
  RATE_LIMITING_BUFFER: int = config("BITVAVO_API_UPGRADED_RATE_LIMITING_BUFFER", default=25, cast=int)
@@ -2,16 +2,17 @@
2
2
  This file contains all type aliases that I use within the lib,
3
3
  to clearify the intention or semantics/meaning/unit of a variable
4
4
  """
5
- from typing import Any, Dict
5
+
6
+ from typing import Any
6
7
 
7
8
  # type simplification
8
- anydict = Dict[str, Any]
9
- strdict = Dict[str, str]
10
- intdict = Dict[str, int]
11
- errordict = Dict[str, Any] # same type as anydict, but the semantics/meaning is different
9
+ anydict = dict[str, Any]
10
+ strdict = dict[str, str]
11
+ intdict = dict[str, int]
12
+ errordict = dict[str, Any] # same type as anydict, but the semantics/meaning is different
12
13
 
13
- # note: You can also use these for type conversion, so instead of int(some_float / 1000), you can just do ms(some_float / 1000)
14
- # units
14
+ # note: You can also use these for type conversion, so instead of int(some_float / 1000), you can just do ms(some_float
15
+ # / 1000) units
15
16
  s = int # seconds
16
17
  ms = int # milliseconds
17
18
  us = int # microseconds, normally written as μs, but nobody has the μ (mu) symbol on their keyboard, so `us` it is.