Skip to content

Commit 9154651

Browse files
authored
Support + test Python 3.9-3.13 (#116)
Fixes the 3 mypy errors: ``` hyperliquid/info.py: note: In member "__init__" of class "Info": hyperliquid/info.py:29:31: error: Incompatible types in assignment (expression has type "None", variable has type "WebsocketManager") [assignment] self.ws_manager = None ^~~~ hyperliquid/exchange.py: note: In member "market_close" of class "Exchange": hyperliquid/exchange.py:215:23: error: Incompatible types in assignment (expression has type "str", variable has type "ChecksumAddress") [assignment] address = self.account_address ^~~~~~~~~~~~~~~~~~~~ hyperliquid/exchange.py:217:23: error: Incompatible types in assignment (expression has type "str", variable has type "ChecksumAddress") [assignment] address = self.vault_address ^~~~~~~~~~~~~~~~~~ ```
1 parent a4fe387 commit 9154651

File tree

11 files changed

+1938
-1379
lines changed

11 files changed

+1938
-1379
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ jobs:
2020
runs-on: ubuntu-24.04
2121
strategy:
2222
matrix:
23-
python-version: ['3.9', '3.11']
23+
# https://devguide.python.org/versions/
24+
# 3.9: lower bound = lowest Python non-EOL version
25+
# 3.13: upper bound = latest Python stable version
26+
python-version: ['3.9', '3.13']
2427
steps:
2528
- uses: actions/checkout@v4
2629

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
#* Variables
22
SHELL := /usr/bin/env bash -o pipefail -o errexit
33

4+
#* Lockfile handling
5+
lockfile-update:
6+
poetry lock -n
7+
8+
lockfile-update-full:
9+
poetry lock -n --regenerate
10+
411
#* Installation
512
install:
6-
poetry lock -n --no-update && poetry export --without-hashes > requirements.txt
713
poetry install -n
8-
-poetry run mypy --install-types --non-interactive ./
14+
15+
install-types:
16+
poetry run mypy --install-types --non-interactive ./
917

1018
#* Poetry
1119
poetry-download:
1220
curl -sSL https://install.python-poetry.org | python -
1321

1422
#* Formatters
1523
codestyle:
16-
poetry run pyupgrade --exit-zero-even-if-changed --py37-plus **/*.py
24+
poetry run pyupgrade --exit-zero-even-if-changed --py39-plus **/*.py
1725
poetry run isort --settings-path pyproject.toml ./
1826
poetry run black --config pyproject.toml ./
1927

examples/basic_staking.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ def main():
1919
print(json.dumps(user_stakes, indent=2))
2020

2121
# Get the user staking reward history and print information
22-
user_staking_rewards= info.user_staking_rewards(address)
22+
user_staking_rewards = info.user_staking_rewards(address)
2323
print("Most recent staking rewards:")
2424
print(json.dumps(user_staking_rewards[:5], indent=2))
2525

26+
2627
if __name__ == "__main__":
27-
main()
28+
main()

examples/rounding.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Prices are precise to the lesser of 5 significant figures or 6 decimals.
1010
You can find the szDecimals for an asset by making a meta request to the info endpoint
1111
"""
12+
1213
import json
1314

1415
import example_utils

hyperliquid/exchange.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def market_close(
210210
cloid: Optional[Cloid] = None,
211211
builder: Optional[BuilderInfo] = None,
212212
) -> Any:
213-
address = self.wallet.address
213+
address: str = self.wallet.address
214214
if self.account_address:
215215
address = self.account_address
216216
if self.vault_address:

hyperliquid/info.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ def __init__(
2222
spot_meta: Optional[SpotMeta] = None,
2323
):
2424
super().__init__(base_url)
25+
self.ws_manager: Optional[WebsocketManager] = None
2526
if not skip_ws:
2627
self.ws_manager = WebsocketManager(self.base_url)
2728
self.ws_manager.start()
28-
else:
29-
self.ws_manager = None
3029
if meta is None:
3130
meta = self.meta()
3231

@@ -500,7 +499,7 @@ def user_fees(self, address: str) -> Any:
500499
}
501500
"""
502501
return self.post("/info", {"type": "userFees", "user": address})
503-
502+
504503
def user_staking_summary(self, address: str) -> Any:
505504
"""Retrieve the staking summary associated with a user.
506505
POST /info
@@ -516,7 +515,7 @@ def user_staking_summary(self, address: str) -> Any:
516515
}
517516
"""
518517
return self.post("/info", {"type": "delegatorSummary", "user": address})
519-
518+
520519
def user_staking_delegations(self, address: str) -> Any:
521520
"""Retrieve the user's staking delegations.
522521
POST /info
@@ -533,7 +532,7 @@ def user_staking_delegations(self, address: str) -> Any:
533532
]
534533
"""
535534
return self.post("/info", {"type": "delegations", "user": address})
536-
535+
537536
def user_staking_rewards(self, address: str) -> Any:
538537
"""Retrieve the historic staking rewards associated with a user.
539538
POST /info

hyperliquid/utils/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __str__(self):
128128

129129
def __repr__(self):
130130
return str(self._raw_cloid)
131-
131+
132132
@staticmethod
133133
def from_int(cloid: int) -> Cloid:
134134
return Cloid(f"{cloid:#034x}")

poetry.lock

Lines changed: 1904 additions & 1256 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Poetry pyproject.toml: https://python-poetry.org/docs/pyproject/
22
[build-system]
3-
requires = ["poetry_core>=1.0.0"]
3+
requires = ["poetry-core>=2.0.0"]
44
build-backend = "poetry.core.masonry.api"
55

66
[tool.poetry]
@@ -27,44 +27,45 @@ classifiers = [ #! Update me
2727
"Topic :: Software Development :: Libraries :: Python Modules",
2828
"License :: OSI Approved :: MIT License",
2929
"Programming Language :: Python :: 3",
30-
"Programming Language :: Python :: 3.8",
3130
"Programming Language :: Python :: 3.9",
3231
"Programming Language :: Python :: 3.10",
3332
"Programming Language :: Python :: 3.11",
3433
"Programming Language :: Python :: 3.12",
34+
"Programming Language :: Python :: 3.13",
3535
]
3636

3737
[tool.poetry.scripts]
3838
# Entry points for the package https://python-poetry.org/docs/pyproject/#scripts
3939
"hyperliquid-python-sdk" = "hyperliquid.__main__:app"
4040

4141
[tool.poetry.dependencies]
42-
python = "^3.8"
42+
python = "^3.9"
4343
eth-utils = ">=2.1.0,<6.0.0"
4444
eth-account = ">=0.10.0,<0.14.0"
4545
websocket-client = "^1.5.1"
4646
requests = "^2.31.0"
4747
msgpack = "^1.0.5"
4848

49-
[tool.poetry.dev-dependencies]
50-
python = "3.10.10"
49+
[tool.poetry.group.dev.dependencies]
50+
python = "^3.10"
5151
pytest = "^7.2.1"
5252
pytest-recording = "^0.12.2"
5353
bandit = "^1.7.1"
54-
black = "^22.3.0"
54+
black = "^24.8.0"
5555
darglint = "^1.8.1"
5656
isort = {extras = ["colors"], version = "^5.10.1"}
57-
mypy = "^0.981"
57+
mypy = "^0.991"
5858
mypy-extensions = "^0.4.3"
5959
pre-commit = "^2.15.0"
6060
pydocstyle = "^6.1.1"
6161
pylint = "^2.11.1"
6262
pyupgrade = "^2.29.1"
63-
safety = "^1.10.3"
63+
safety = "^2.2.1"
6464
coverage = "^6.1.2"
6565
coverage-badge = "^1.1.0"
6666
pytest-cov = "^4.0.0"
6767
vcrpy = { version = "^7.0.0", python = "3.10.10" }
68+
types-requests = "^2.31.0"
6869

6970
[tool.black]
7071
line-length = 120

requirements-ci.txt

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)