Commit 309bf25
Fix Python 3.9 compatibility by adding annotations future import (#156)
Summary:
Pull Request resolved: #156
The balance library was failing to import in Python 3.9 due to using the `|` union operator in type hints, which is only supported in Python 3.10+. The error manifested as:
```
TypeError: unsupported operand type(s) for |: 'types.GenericAlias' and 'type'
```
This occurred in the type annotation `dict[str, dict[str, str] | pd.Series]` in the `adjust_null` function.
The fix adds `annotations` to the `from __future__ import` statement, which enables PEP 563 postponed evaluation of annotations. This causes all type hints to be stored as strings and evaluated lazily, making the Python 3.10+ union syntax compatible with Python 3.9.
Differential Revision: D87538672
fbshipit-source-id: d6e92e47b9dce6c12b638daf9a5e75b43fa8e2a21 parent 66fb30b commit 309bf25
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | 16 | | |
11 | 17 | | |
| |||
0 commit comments