From a1a912672d49c097a744cf83bb1cf85b740e94be Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 23 Nov 2023 01:36:11 +0100 Subject: [PATCH] cleanup __repr__ and __str__ in python binding to make all streamable types have a __repr__() based on the rust Debug trait. The BLS types also have a separate __str__() --- chia-bls/src/gtelement.rs | 12 +++-- chia-bls/src/public_key.rs | 17 +++--- chia-bls/src/secret_key.rs | 14 ++--- chia-bls/src/signature.rs | 17 +++--- chia-protocol/src/coin.rs | 2 +- chia_py_streamable_macro/src/lib.rs | 4 +- wheel/chia_rs.pyi | 81 +++-------------------------- wheel/generate_type_stubs.py | 9 +++- 8 files changed, 56 insertions(+), 100 deletions(-) diff --git a/chia-bls/src/gtelement.rs b/chia-bls/src/gtelement.rs index 818085f1c..6d04eabaa 100644 --- a/chia-bls/src/gtelement.rs +++ b/chia-bls/src/gtelement.rs @@ -51,7 +51,7 @@ impl GTElement { } } #[cfg(feature = "py-bindings")] -#[cfg_attr(feature = "py-bindings", pymethods)] +#[pymethods] impl GTElement { #[classattr] #[pyo3(name = "SIZE")] @@ -63,9 +63,8 @@ impl GTElement { Ok(Self::from_bytes(&bytes)) } - pub fn __repr__(&self) -> String { - let bytes = self.to_bytes(); - format!("", &hex::encode(bytes)) + fn __str__(&self) -> pyo3::PyResult { + Ok(hex::encode(self.to_bytes())) } pub fn __mul__(&self, rhs: &Self) -> Self { @@ -137,7 +136,10 @@ impl FromJsonDict for GTElement { impl fmt::Debug for GTElement { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str(&hex::encode(self.to_bytes())) + formatter.write_fmt(format_args!( + "", + &hex::encode(self.to_bytes()) + )) } } diff --git a/chia-bls/src/public_key.rs b/chia-bls/src/public_key.rs index 33a376ad1..b02b627a7 100644 --- a/chia-bls/src/public_key.rs +++ b/chia-bls/src/public_key.rs @@ -157,7 +157,7 @@ impl PublicKey { } #[cfg(feature = "py-bindings")] -#[cfg_attr(feature = "py-bindings", pymethods)] +#[pymethods] impl PublicKey { #[classattr] const SIZE: usize = 48; @@ -188,9 +188,8 @@ impl PublicKey { self.get_fingerprint() } - pub fn __repr__(&self) -> String { - let bytes = self.to_bytes(); - format!("", &hex::encode(bytes)) + fn __str__(&self) -> pyo3::PyResult { + Ok(hex::encode(self.to_bytes())) } pub fn __add__(&self, rhs: &Self) -> Self { @@ -291,7 +290,10 @@ impl Add<&PublicKey> for PublicKey { impl fmt::Debug for PublicKey { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str(&hex::encode(self.to_bytes())) + formatter.write_fmt(format_args!( + "", + &hex::encode(self.to_bytes()) + )) } } @@ -600,7 +602,10 @@ mod tests { let mut data = [0u8; 48]; data[0] = 0xc0; let pk = PublicKey::from_bytes(&data).unwrap(); - assert_eq!(format!("{:?}", pk), hex::encode(data)); + assert_eq!( + format!("{:?}", pk), + format!("", hex::encode(data)) + ); } #[test] diff --git a/chia-bls/src/secret_key.rs b/chia-bls/src/secret_key.rs index ceb0d38a6..af61fcba7 100644 --- a/chia-bls/src/secret_key.rs +++ b/chia-bls/src/secret_key.rs @@ -213,7 +213,10 @@ impl AddAssign<&SecretKey> for SecretKey { impl fmt::Debug for SecretKey { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str(&hex::encode(self.to_bytes())) + formatter.write_fmt(format_args!( + "", + &hex::encode(self.to_bytes()) + )) } } @@ -260,7 +263,7 @@ impl DerivableKey for SecretKey { } #[cfg(feature = "py-bindings")] -#[cfg_attr(feature = "py-bindings", pymethods)] +#[pymethods] impl SecretKey { #[classattr] const PRIVATE_KEY_SIZE: usize = 32; @@ -273,9 +276,8 @@ impl SecretKey { self.public_key() } - pub fn __repr__(&self) -> String { - let bytes = self.to_bytes(); - format!("", &hex::encode(bytes)) + fn __str__(&self) -> pyo3::PyResult { + Ok(hex::encode(self.to_bytes())) } } @@ -411,7 +413,7 @@ mod tests { fn test_debug() { let sk_hex = "52d75c4707e39595b27314547f9723e5530c01198af3fc5849d9a7af65631efb"; let sk = SecretKey::from_bytes(&<[u8; 32]>::from_hex(sk_hex).unwrap()).unwrap(); - assert_eq!(format!("{:?}", sk), sk_hex); + assert_eq!(format!("{:?}", sk), format!("", sk_hex)); } #[test] diff --git a/chia-bls/src/signature.rs b/chia-bls/src/signature.rs index 4e3c77574..5d268a593 100644 --- a/chia-bls/src/signature.rs +++ b/chia-bls/src/signature.rs @@ -167,7 +167,10 @@ impl Hash for Signature { impl fmt::Debug for Signature { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str(&hex::encode(self.to_bytes())) + formatter.write_fmt(format_args!( + "", + &hex::encode(self.to_bytes()) + )) } } @@ -271,7 +274,7 @@ impl ToClvm for Signature { } #[cfg(feature = "py-bindings")] -#[cfg_attr(feature = "py-bindings", pymethods)] +#[pymethods] impl Signature { #[classattr] const SIZE: usize = 96; @@ -298,9 +301,8 @@ impl Signature { Self::generator() } - pub fn __repr__(&self) -> String { - let bytes = self.to_bytes(); - format!("", &hex::encode(bytes)) + fn __str__(&self) -> pyo3::PyResult { + Ok(hex::encode(self.to_bytes())) } pub fn __add__(&self, rhs: &Self) -> Self { @@ -1055,7 +1057,10 @@ mod tests { let mut data = [0u8; 96]; data[0] = 0xc0; let sig = Signature::from_bytes(&data).unwrap(); - assert_eq!(format!("{:?}", sig), hex::encode(data)); + assert_eq!( + format!("{:?}", sig), + format!("", hex::encode(data)) + ); } #[test] diff --git a/chia-protocol/src/coin.rs b/chia-protocol/src/coin.rs index e66551172..737edc658 100644 --- a/chia-protocol/src/coin.rs +++ b/chia-protocol/src/coin.rs @@ -46,7 +46,7 @@ impl Coin { } #[cfg(feature = "py-bindings")] -#[cfg_attr(feature = "py-bindings", pymethods)] +#[pymethods] impl Coin { fn name<'p>(&self, py: pyo3::Python<'p>) -> pyo3::PyResult<&'p pyo3::types::PyBytes> { Ok(pyo3::types::PyBytes::new(py, &self.coin_id())) diff --git a/chia_py_streamable_macro/src/lib.rs b/chia_py_streamable_macro/src/lib.rs index 56cc2d1ea..b23dc299f 100644 --- a/chia_py_streamable_macro/src/lib.rs +++ b/chia_py_streamable_macro/src/lib.rs @@ -52,8 +52,8 @@ pub fn py_streamable_macro(input: proc_macro::TokenStream) -> proc_macro::TokenS let mut py_protocol = quote! { #[pyo3::pymethods] impl #ident { - fn __str__(&self) -> pyo3::PyResult { - Ok(format!("{:?}", self)) + fn __repr__(&self) -> pyo3::PyResult { + Ok(format!("{self:?}")) } fn __richcmp__(&self, other: pyo3::PyRef, op: pyo3::class::basic::CompareOp) -> pyo3::Py { diff --git a/wheel/chia_rs.pyi b/wheel/chia_rs.pyi index 8b12895d3..67d4f76a8 100644 --- a/wheel/chia_rs.pyi +++ b/wheel/chia_rs.pyi @@ -90,13 +90,14 @@ class G1Element: def from_bytes_unchecked(b: bytes) -> G1Element: ... @staticmethod def generator() -> G1Element: ... + def __str__(self) -> str: ... + def __repr__(self) -> str: ... def __add__(self, other: G1Element) -> G1Element: ... def __iadd__(self, other: G1Element) -> G1Element: ... def __init__( self ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> G1Element: ... @@ -122,13 +123,14 @@ class G2Element: def pair(self, other: G1Element) -> GTElement: ... @staticmethod def generator() -> G2Element: ... + def __str__(self) -> str: ... + def __repr__(self) -> str: ... def __add__(self, other: G2Element) -> G2Element: ... def __iadd__(self, other: G2Element) -> G2Element: ... def __init__( self ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> G2Element: ... @@ -150,13 +152,14 @@ class GTElement: SIZE: ClassVar[int] = ... @staticmethod def from_bytes_unchecked(b: bytes) -> GTElement: ... + def __str__(self) -> str: ... + def __repr__(self) -> str: ... def __mul__(self, rhs: GTElement) -> GTElement: ... def __imul__(self, rhs: GTElement) -> GTElement : ... def __init__( self ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> GTElement: ... @@ -178,11 +181,12 @@ class PrivateKey: PRIVATE_KEY_SIZE: ClassVar[int] = ... def sign_g2(self, msg: bytes, dst: bytes) -> G2Element: ... def get_g1(self) -> G1Element: ... + def __str__(self) -> str: ... + def __repr__(self) -> str: ... def __init__( self ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> PrivateKey: ... @@ -243,7 +247,6 @@ class Spend: flags: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> Spend: ... @@ -286,7 +289,6 @@ class SpendBundleConditions: addition_amount: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> SpendBundleConditions: ... @@ -315,7 +317,6 @@ class Message: data: bytes ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> Message: ... @@ -350,7 +351,6 @@ class Handshake: capabilities: Sequence[(int, String)] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> Handshake: ... @@ -381,7 +381,6 @@ class ClassgroupElement: data: bytes100 ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> ClassgroupElement: ... @@ -411,7 +410,6 @@ class Coin: amount: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> Coin: ... @@ -440,7 +438,6 @@ class CoinSpend: solution: Program ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> CoinSpend: ... @@ -469,7 +466,6 @@ class CoinState: created_height: Optional[int] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> CoinState: ... @@ -500,7 +496,6 @@ class EndOfSubSlotBundle: proofs: SubSlotProofs ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> EndOfSubSlotBundle: ... @@ -525,7 +520,6 @@ class FeeRate: mojos_per_clvm_cost: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> FeeRate: ... @@ -554,7 +548,6 @@ class FeeEstimate: estimated_fee_rate: FeeRate ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> FeeEstimate: ... @@ -581,7 +574,6 @@ class FeeEstimateGroup: estimates: Sequence[FeeEstimate] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> FeeEstimateGroup: ... @@ -616,7 +608,6 @@ class TransactionsInfo: reward_claims_incorporated: Sequence[Coin] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> TransactionsInfo: ... @@ -651,7 +642,6 @@ class FoliageTransactionBlock: transactions_info_hash: bytes ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> FoliageTransactionBlock: ... @@ -684,7 +674,6 @@ class FoliageBlockData: extension_data: bytes ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> FoliageBlockData: ... @@ -719,7 +708,6 @@ class Foliage: foliage_transaction_block_signature: Optional[G2Element] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> Foliage: ... @@ -774,7 +762,6 @@ class FullBlock: transactions_generator_ref_list: Sequence[int] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> FullBlock: ... @@ -828,7 +815,6 @@ class HeaderBlock: transactions_info: Optional[TransactionsInfo] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> HeaderBlock: ... @@ -855,7 +841,6 @@ class PoolTarget: max_height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> PoolTarget: ... @@ -880,7 +865,6 @@ class Program: a0: bytes ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> Program: ... @@ -915,7 +899,6 @@ class ProofOfSpace: proof: bytes ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> ProofOfSpace: ... @@ -954,7 +937,6 @@ class RewardChainBlockUnfinished: reward_chain_sp_signature: G2Element ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RewardChainBlockUnfinished: ... @@ -1006,7 +988,6 @@ class RewardChainBlock: is_transaction_block: bool ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RewardChainBlock: ... @@ -1037,7 +1018,6 @@ class ChallengeBlockInfo: challenge_chain_ip_vdf: VDFInfo ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> ChallengeBlockInfo: ... @@ -1070,7 +1050,6 @@ class ChallengeChainSubSlot: new_difficulty: Optional[int] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> ChallengeChainSubSlot: ... @@ -1095,7 +1074,6 @@ class InfusedChallengeChainSubSlot: infused_challenge_chain_end_of_slot_vdf: VDFInfo ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> InfusedChallengeChainSubSlot: ... @@ -1126,7 +1104,6 @@ class RewardChainSubSlot: deficit: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RewardChainSubSlot: ... @@ -1155,7 +1132,6 @@ class SubSlotProofs: reward_chain_slot_proof: VDFProof ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> SubSlotProofs: ... @@ -1182,7 +1158,6 @@ class SpendBundle: aggregated_signature: G2Element ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> SpendBundle: ... @@ -1215,7 +1190,6 @@ class SubEpochSummary: new_sub_slot_iters: Optional[int] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> SubEpochSummary: ... @@ -1260,7 +1234,6 @@ class UnfinishedBlock: transactions_generator_ref_list: Sequence[int] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> UnfinishedBlock: ... @@ -1289,7 +1262,6 @@ class VDFInfo: output: ClassgroupElement ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> VDFInfo: ... @@ -1318,7 +1290,6 @@ class VDFProof: normalized_to_identity: bool ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> VDFProof: ... @@ -1345,7 +1316,6 @@ class RequestPuzzleSolution: height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RequestPuzzleSolution: ... @@ -1376,7 +1346,6 @@ class PuzzleSolutionResponse: solution: Program ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> PuzzleSolutionResponse: ... @@ -1401,7 +1370,6 @@ class RespondPuzzleSolution: response: PuzzleSolutionResponse ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondPuzzleSolution: ... @@ -1428,7 +1396,6 @@ class RejectPuzzleSolution: height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RejectPuzzleSolution: ... @@ -1453,7 +1420,6 @@ class SendTransaction: transaction: SpendBundle ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> SendTransaction: ... @@ -1482,7 +1448,6 @@ class TransactionAck: error: Optional[String] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> TransactionAck: ... @@ -1513,7 +1478,6 @@ class NewPeakWallet: fork_point_with_previous_peak: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> NewPeakWallet: ... @@ -1538,7 +1502,6 @@ class RequestBlockHeader: height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RequestBlockHeader: ... @@ -1563,7 +1526,6 @@ class RespondBlockHeader: header_block: HeaderBlock ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondBlockHeader: ... @@ -1588,7 +1550,6 @@ class RejectHeaderRequest: height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RejectHeaderRequest: ... @@ -1617,7 +1578,6 @@ class RequestRemovals: coin_names: Optional[Sequence[bytes32]] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RequestRemovals: ... @@ -1648,7 +1608,6 @@ class RespondRemovals: proofs: Optional[Sequence[(bytes32, bytes)]] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondRemovals: ... @@ -1675,7 +1634,6 @@ class RejectRemovalsRequest: header_hash: bytes ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RejectRemovalsRequest: ... @@ -1704,7 +1662,6 @@ class RequestAdditions: puzzle_hashes: Optional[Sequence[bytes32]] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RequestAdditions: ... @@ -1735,7 +1692,6 @@ class RespondAdditions: proofs: Optional[Sequence[(bytes32, bytes, Optional[bytes])]] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondAdditions: ... @@ -1762,7 +1718,6 @@ class RejectAdditionsRequest: header_hash: bytes ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RejectAdditionsRequest: ... @@ -1791,7 +1746,6 @@ class RespondBlockHeaders: header_blocks: Sequence[HeaderBlock] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondBlockHeaders: ... @@ -1818,7 +1772,6 @@ class RejectBlockHeaders: end_height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RejectBlockHeaders: ... @@ -1847,7 +1800,6 @@ class RequestBlockHeaders: return_filter: bool ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RequestBlockHeaders: ... @@ -1874,7 +1826,6 @@ class RequestHeaderBlocks: end_height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RequestHeaderBlocks: ... @@ -1901,7 +1852,6 @@ class RejectHeaderBlocks: end_height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RejectHeaderBlocks: ... @@ -1930,7 +1880,6 @@ class RespondHeaderBlocks: header_blocks: Sequence[HeaderBlock] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondHeaderBlocks: ... @@ -1957,7 +1906,6 @@ class RegisterForPhUpdates: min_height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RegisterForPhUpdates: ... @@ -1986,7 +1934,6 @@ class RespondToPhUpdates: coin_states: Sequence[CoinState] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondToPhUpdates: ... @@ -2013,7 +1960,6 @@ class RegisterForCoinUpdates: min_height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RegisterForCoinUpdates: ... @@ -2042,7 +1988,6 @@ class RespondToCoinUpdates: coin_states: Sequence[CoinState] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondToCoinUpdates: ... @@ -2073,7 +2018,6 @@ class CoinStateUpdate: items: Sequence[CoinState] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> CoinStateUpdate: ... @@ -2098,7 +2042,6 @@ class RequestChildren: coin_name: bytes ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RequestChildren: ... @@ -2123,7 +2066,6 @@ class RespondChildren: coin_states: Sequence[CoinState] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondChildren: ... @@ -2150,7 +2092,6 @@ class RequestSesInfo: end_height: int ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RequestSesInfo: ... @@ -2177,7 +2118,6 @@ class RespondSesInfo: heights: Sequence[Sequence[int]] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondSesInfo: ... @@ -2202,7 +2142,6 @@ class RequestFeeEstimates: time_targets: Sequence[int] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RequestFeeEstimates: ... @@ -2227,7 +2166,6 @@ class RespondFeeEstimates: estimates: FeeEstimateGroup ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> RespondFeeEstimates: ... @@ -2278,7 +2216,6 @@ class SubSlotData: total_iters: Optional[int] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> SubSlotData: ... @@ -2307,7 +2244,6 @@ class SubEpochChallengeSegment: rc_slot_end_info: Optional[VDFInfo] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> SubEpochChallengeSegment: ... @@ -2332,7 +2268,6 @@ class SubEpochSegments: challenge_segments: Sequence[SubEpochChallengeSegment] ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> SubEpochSegments: ... diff --git a/wheel/generate_type_stubs.py b/wheel/generate_type_stubs.py index 2c427733b..7a9a7572a 100644 --- a/wheel/generate_type_stubs.py +++ b/wheel/generate_type_stubs.py @@ -40,7 +40,6 @@ def __init__( self{init_args} ) -> None: ... def __hash__(self) -> int: ... - def __str__(self) -> str: ... def __repr__(self) -> str: ... def __richcmp__(self) -> Any: ... def __deepcopy__(self) -> {name}: ... @@ -288,6 +287,8 @@ def derive_child_pk_unhardened(pk: G1Element, index: int) -> G1Element: ... "def from_bytes_unchecked(b: bytes) -> G1Element: ...", "@staticmethod", "def generator() -> G1Element: ...", + "def __str__(self) -> str: ...", + "def __repr__(self) -> str: ...", "def __add__(self, other: G1Element) -> G1Element: ...", "def __iadd__(self, other: G1Element) -> G1Element: ...", ]) @@ -299,6 +300,8 @@ def derive_child_pk_unhardened(pk: G1Element, index: int) -> G1Element: ... "def pair(self, other: G1Element) -> GTElement: ...", "@staticmethod", "def generator() -> G2Element: ...", + "def __str__(self) -> str: ...", + "def __repr__(self) -> str: ...", "def __add__(self, other: G2Element) -> G2Element: ...", "def __iadd__(self, other: G2Element) -> G2Element: ...", ]) @@ -306,6 +309,8 @@ def derive_child_pk_unhardened(pk: G1Element, index: int) -> G1Element: ... "SIZE: ClassVar[int] = ...", "@staticmethod", "def from_bytes_unchecked(b: bytes) -> GTElement: ...", + "def __str__(self) -> str: ...", + "def __repr__(self) -> str: ...", "def __mul__(self, rhs: GTElement) -> GTElement: ...", "def __imul__(self, rhs: GTElement) -> GTElement : ...", ]) @@ -313,6 +318,8 @@ def derive_child_pk_unhardened(pk: G1Element, index: int) -> G1Element: ... "PRIVATE_KEY_SIZE: ClassVar[int] = ...", "def sign_g2(self, msg: bytes, dst: bytes) -> G2Element: ...", "def get_g1(self) -> G1Element: ...", + "def __str__(self) -> str: ...", + "def __repr__(self) -> str: ...", ]) print_class(f, "Spend",