Skip to content

Commit 281df10

Browse files
Copilotrichardkiss
andcommitted
Address code review: add Python 3.12-3.13 to test matrix, use Literal types, fix hash_f annotation
Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
1 parent 98cc1ca commit 281df10

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
max-parallel: 4
1717
matrix:
18-
python-version: [3.8, 3.9, "3.10", "3.11"]
18+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
1919

2020
steps:
2121
- name: Checkout Code

pycoin/ecdsa/intstream.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from typing import Literal
12

23

3-
def to_bytes(v: int, length: int, byteorder: str = "big") -> bytes:
4+
def to_bytes(v: int, length: int, byteorder: Literal["big", "little"] = "big") -> bytes:
45
"""This is the same functionality as ``int.to_bytes`` in python 3"""
5-
return v.to_bytes(length, byteorder=byteorder) # type: ignore[arg-type]
6+
return v.to_bytes(length, byteorder=byteorder)
67

78

8-
def from_bytes(bytes: bytes, byteorder: str = "big", signed: bool = False) -> int:
9+
def from_bytes(bytes: bytes, byteorder: Literal["big", "little"] = "big", signed: bool = False) -> int:
910
"""This is the same functionality as ``int.from_bytes`` in python 3"""
10-
return int.from_bytes(bytes, byteorder=byteorder, signed=signed) # type: ignore[arg-type]
11+
return int.from_bytes(bytes, byteorder=byteorder, signed=signed)

pycoin/ecdsa/rfc6979.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def bit_length(v: int) -> int:
1010
return v.bit_length()
1111

1212

13-
def deterministic_generate_k(generator_order: int, secret_exponent: int, val: int, hash_f: Callable[[], Any] = hashlib.sha256) -> int:
13+
def deterministic_generate_k(generator_order: int, secret_exponent: int, val: int, hash_f: Callable[..., Any] = hashlib.sha256) -> int:
1414
"""
1515
:param generator_order: result from `pycoin.ecdsa.Generator.Generator.order`,
1616
necessary to ensure the k value is within bound

0 commit comments

Comments
 (0)