Skip to content

Commit d2ad8e1

Browse files
committed
Add typing_extensions for Python 3.8-3.10 compatibility with TypedDict Unpack
1 parent c2a928a commit d2ad8e1

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

TYPE_HINTS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,16 @@ class CalendarStrategyParams(StrategyParams):
7979
All strategy functions now use `Unpack[StrategyParams]`:
8080

8181
```python
82+
from typing_extensions import Unpack
83+
8284
def iron_condor(
8385
data: pd.DataFrame,
8486
**kwargs: Unpack[StrategyParams]
8587
) -> pd.DataFrame:
8688
...
8789
```
8890

89-
This preserves backward compatibility while adding type information.
91+
This preserves backward compatibility while adding type information. Note that `Unpack` is imported from `typing_extensions` for compatibility with Python 3.8+.
9092

9193
## Exporting Types
9294

docs/api-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ See the [Examples page](examples.md) for detailed usage examples.
278278
All functions include full type hints with TypedDict for IDE autocomplete support:
279279

280280
```python
281-
from typing import Unpack
282281
import pandas as pd
282+
from typing_extensions import Unpack
283283
from optopsy import StrategyParams
284284

285285
def long_calls(data: pd.DataFrame, **kwargs: Unpack[StrategyParams]) -> pd.DataFrame:

optopsy/strategies.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from typing import Any, Dict, List, Tuple, Unpack
1+
from typing import Any, Dict, List, Tuple
2+
23
import pandas as pd
4+
from typing_extensions import Unpack
35
from .core import _calls, _puts, _process_strategy, _process_calendar_strategy
46
from .types import StrategyParams, CalendarStrategyParams
57
from .definitions import (

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
],
2222
python_requires=">=3.8",
2323
packages=["optopsy"],
24-
install_requires=["pandas", "numpy"],
24+
install_requires=["pandas", "numpy", "typing_extensions>=4.0.0"],
2525
)

0 commit comments

Comments
 (0)