diff --git a/duniterpy/api/bma/tx.py b/duniterpy/api/bma/tx.py index b46cf62cdc9fbb3683758c3f81b43c9408845ed4..17fe68caa28ff8c5ab29d002134f90ae4133222e 100644 --- a/duniterpy/api/bma/tx.py +++ b/duniterpy/api/bma/tx.py @@ -181,7 +181,7 @@ def blocks(client: Client, pubkey: str, start: int, end: int) -> dict: :return: """ return client.get( - MODULE + "/history/%s/blocks/%s/%s" % (pubkey, start, end), + MODULE + f"/history/{pubkey}/blocks/{start}/{end}", schema=HISTORY_SCHEMA, ) @@ -197,5 +197,5 @@ def times(client: Client, pubkey: str, start: int, end: int) -> dict: :return: """ return client.get( - MODULE + "/history/%s/times/%s/%s" % (pubkey, start, end), schema=HISTORY_SCHEMA + MODULE + f"/history/{pubkey}/times/{start}/{end}", schema=HISTORY_SCHEMA ) diff --git a/duniterpy/api/client.py b/duniterpy/api/client.py index fbffc341f9cf4b2dbd1d5424ed1818ad954d1722..f0264c020101c0b4f80825543972b7d4459c14cd 100644 --- a/duniterpy/api/client.py +++ b/duniterpy/api/client.py @@ -70,9 +70,7 @@ def parse_error(text: str) -> dict: data = json.loads(text) jsonschema.validate(data, ERROR_SCHEMA) except (TypeError, json.decoder.JSONDecodeError) as e: - raise jsonschema.ValidationError( - "Could not parse json : {0}".format(str(e)) - ) from e + raise jsonschema.ValidationError(f"Could not parse json : {str(e)}") from e return data @@ -92,7 +90,7 @@ def parse_response(response: str, schema: dict) -> Any: return data except (TypeError, json.decoder.JSONDecodeError) as exception: raise jsonschema.ValidationError( - "Could not parse json : {0}".format(str(exception)) + f"Could not parse json : {str(exception)}" ) from exception @@ -341,9 +339,7 @@ class Client: self.endpoint = _endpoint if isinstance(self.endpoint, endpoint.UnknownEndpoint): - raise NotImplementedError( - "{0} endpoint in not supported".format(self.endpoint.api) - ) + raise NotImplementedError(f"{self.endpoint.api} endpoint in not supported") self.proxy = proxy diff --git a/duniterpy/api/endpoint.py b/duniterpy/api/endpoint.py index c6f0e07742f399bda23df31d0acf29bfa1750cdc..d82977ba36f7e59f80fe39e63e63fce5341cb7c8 100644 --- a/duniterpy/api/endpoint.py +++ b/duniterpy/api/endpoint.py @@ -111,7 +111,7 @@ class UnknownEndpoint(Endpoint): """ doc = self.api for p in self.properties: - doc += " {0}".format(p) + doc += f" {p}" return doc def conn_handler(self, proxy: str = None) -> ConnectionHandler: @@ -124,9 +124,7 @@ class UnknownEndpoint(Endpoint): return ConnectionHandler("", "", "", 0, "") def __str__(self) -> str: - return "{0} {1}".format( - self.api, " ".join(["{0}".format(p) for p in self.properties]) - ) + return "{} {}".format(self.api, " ".join([f"{p}" for p in self.properties])) def __eq__(self, other: Any) -> bool: if not isinstance(other, UnknownEndpoint): @@ -185,10 +183,10 @@ class BMAEndpoint(Endpoint): :return: """ return BMAEndpoint.API + "{DNS}{IPv4}{IPv6}{PORT}".format( - DNS=(" {0}".format(self.host) if self.host else ""), - IPv4=(" {0}".format(self.ipv4) if self.ipv4 else ""), - IPv6=(" {0}".format(self.ipv6) if self.ipv6 else ""), - PORT=(" {0}".format(self.port) if self.port else ""), + DNS=(f" {self.host}" if self.host else ""), + IPv4=(f" {self.ipv4}" if self.ipv4 else ""), + IPv6=(f" {self.ipv6}" if self.ipv6 else ""), + PORT=(f" {self.port}" if self.port else ""), ) def conn_handler(self, proxy: str = None) -> ConnectionHandler: @@ -204,7 +202,7 @@ class BMAEndpoint(Endpoint): ) elif self.ipv6: conn_handler = ConnectionHandler( - "http", "ws", "[{0}]".format(self.ipv6), self.port, "", proxy + "http", "ws", f"[{self.ipv6}]", self.port, "", proxy ) else: conn_handler = ConnectionHandler( @@ -301,7 +299,7 @@ class SecuredBMAEndpoint(BMAEndpoint): ) elif self.ipv6: conn_handler = ConnectionHandler( - "https", "wss", "[{0}]".format(self.ipv6), self.port, self.path, proxy + "https", "wss", f"[{self.ipv6}]", self.port, self.path, proxy ) else: conn_handler = ConnectionHandler( @@ -667,7 +665,7 @@ class GVAEndpoint(Endpoint): conn_handler = ConnectionHandler( scheme_http, scheme_ws, - "[{0}]".format(self.ipv6), + f"[{self.ipv6}]", self.port, self.path, proxy, @@ -727,7 +725,7 @@ def endpoint(value: Any) -> Any: if value.startswith(api + " "): result = cls.from_inline(value) else: - raise TypeError("Cannot convert {0} to endpoint".format(value)) + raise TypeError(f"Cannot convert {value} to endpoint") return result diff --git a/duniterpy/api/errors.py b/duniterpy/api/errors.py index 1721292ed88013b5c2a0067ac1675c871a429b3b..e1b6dd5d3b1990d58753635ee4de94afe6f7c39b 100644 --- a/duniterpy/api/errors.py +++ b/duniterpy/api/errors.py @@ -25,7 +25,7 @@ class DuniterError(Exception): :param data: Error informations """ - super().__init__("Error code {0} - {1}".format(data["ucode"], data["message"])) + super().__init__("Error code {} - {}".format(data["ucode"], data["message"])) self.ucode = data["ucode"] self.message = data["message"] diff --git a/duniterpy/documents/block.py b/duniterpy/documents/block.py index 57c31a85230e905a163c46da00dae7b3dd69016d..7a298daf70cd0803a5a88c82a58d2d2a031b7958 100644 --- a/duniterpy/documents/block.py +++ b/duniterpy/documents/block.py @@ -87,18 +87,12 @@ class Block(Document): re_mediantime = re.compile("MedianTime: ([0-9]+)\n") re_universaldividend = re.compile("UniversalDividend: ([0-9]+)\n") re_unitbase = re.compile("UnitBase: ([0-9]+)\n") - re_issuer = re.compile( - "Issuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX) - ) + re_issuer = re.compile(f"Issuer: ({PUBKEY_REGEX})\n") re_issuers_frame = re.compile("IssuersFrame: ([0-9]+)\n") re_issuers_frame_var = re.compile("IssuersFrameVar: (0|-?[1-9]\\d{0,18})\n") re_different_issuers_count = re.compile("DifferentIssuersCount: ([0-9]+)\n") - re_previoushash = re.compile( - "PreviousHash: ({block_hash_regex})\n".format(block_hash_regex=BLOCK_HASH_REGEX) - ) - re_previousissuer = re.compile( - "PreviousIssuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX) - ) + re_previoushash = re.compile(f"PreviousHash: ({BLOCK_HASH_REGEX})\n") + re_previousissuer = re.compile(f"PreviousIssuer: ({PUBKEY_REGEX})\n") re_parameters = re.compile( "Parameters: ([0-9]+\\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):\ ([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+\\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+\\.[0-9]+):\ @@ -111,12 +105,10 @@ class Block(Document): re_leavers = re.compile("Leavers:\n") re_revoked = re.compile("Revoked:\n") re_excluded = re.compile("Excluded:\n") - re_exclusion = re.compile("({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX)) + re_exclusion = re.compile(f"({PUBKEY_REGEX})\n") re_certifications = re.compile("Certifications:\n") re_transactions = re.compile("Transactions:\n") - re_hash = re.compile( - "InnerHash: ({block_hash_regex})\n".format(block_hash_regex=BLOCK_HASH_REGEX) - ) + re_hash = re.compile(f"InnerHash: ({BLOCK_HASH_REGEX})\n") re_nonce = re.compile("Nonce: ([0-9]+)\n") fields_parsers = { @@ -222,7 +214,7 @@ class Block(Document): ) if self.version < documents_versions: raise MalformedDocumentError( - "Block version is too low : {0} < {1}".format( + "Block version is too low : {} < {}".format( self.version, documents_versions ) ) @@ -510,9 +502,7 @@ class Block(Document): tx_lines = "" header_data = Transaction.re_header.match(lines[n]) if header_data is None: - raise MalformedDocumentError( - "Compact transaction ({0})".format(lines[n]) - ) + raise MalformedDocumentError(f"Compact transaction ({lines[n]})") issuers_num = int(header_data.group(2)) inputs_num = int(header_data.group(3)) unlocks_num = int(header_data.group(4)) @@ -597,65 +587,65 @@ MedianTime: {mediantime} mediantime=self.mediantime, ) if self.ud: - doc += "UniversalDividend: {0}\n".format(self.ud) + doc += f"UniversalDividend: {self.ud}\n" - doc += "UnitBase: {0}\n".format(self.unit_base) + doc += f"UnitBase: {self.unit_base}\n" - doc += "Issuer: {0}\n".format(self.issuer) + doc += f"Issuer: {self.issuer}\n" - doc += """IssuersFrame: {0} -IssuersFrameVar: {1} -DifferentIssuersCount: {2} + doc += """IssuersFrame: {} +IssuersFrameVar: {} +DifferentIssuersCount: {} """.format( self.issuers_frame, self.issuers_frame_var, self.different_issuers_count ) if self.number == 0 and self.parameters is not None: str_params = ":".join([str(p) for p in self.parameters]) - doc += "Parameters: {0}\n".format(str_params) + doc += f"Parameters: {str_params}\n" else: - doc += "PreviousHash: {0}\n\ -PreviousIssuer: {1}\n".format( + doc += "PreviousHash: {}\n\ +PreviousIssuer: {}\n".format( self.prev_hash, self.prev_issuer ) - doc += "MembersCount: {0}\n".format(self.members_count) + doc += f"MembersCount: {self.members_count}\n" doc += "Identities:\n" for identity in self.identities: - doc += "{0}\n".format(identity.inline()) + doc += f"{identity.inline()}\n" doc += "Joiners:\n" for joiner in self.joiners: - doc += "{0}\n".format(joiner.inline()) + doc += f"{joiner.inline()}\n" doc += "Actives:\n" for active in self.actives: - doc += "{0}\n".format(active.inline()) + doc += f"{active.inline()}\n" doc += "Leavers:\n" for leaver in self.leavers: - doc += "{0}\n".format(leaver.inline()) + doc += f"{leaver.inline()}\n" doc += "Revoked:\n" for revokation in self.revoked: - doc += "{0}\n".format(revokation.inline()) + doc += f"{revokation.inline()}\n" doc += "Excluded:\n" for exclude in self.excluded: - doc += "{0}\n".format(exclude) + doc += f"{exclude}\n" doc += "Certifications:\n" for cert in self.certifications: - doc += "{0}\n".format(cert.inline()) + doc += f"{cert.inline()}\n" doc += "Transactions:\n" for transaction in self.transactions: - doc += "{0}".format(transaction.compact()) + doc += f"{transaction.compact()}" - doc += "InnerHash: {0}\n".format(self.inner_hash) + doc += f"InnerHash: {self.inner_hash}\n" - doc += "Nonce: {0}\n".format(self.nonce) + doc += f"Nonce: {self.nonce}\n" return doc @@ -734,7 +724,7 @@ Nonce: {nonce} if self.signature is None: raise Exception("Signature is None, can not verify signature") - content_to_verify = "InnerHash: {0}\nNonce: {1}\n".format( + content_to_verify = "InnerHash: {}\nNonce: {}\n".format( self.inner_hash, self.nonce ) diff --git a/duniterpy/documents/block_id.py b/duniterpy/documents/block_id.py index eebee167cf42f6ea2a5804284c6c012db67c00fb..2791f56c2dc144396d07b05bbc57e9be2d7af1bb 100644 --- a/duniterpy/documents/block_id.py +++ b/duniterpy/documents/block_id.py @@ -33,9 +33,7 @@ class BlockID: block_number_regex=BLOCK_NUMBER_REGEX, block_hash_regex=BLOCK_HASH_REGEX ) ) - re_hash = re.compile( - "({block_hash_regex})".format(block_hash_regex=BLOCK_HASH_REGEX) - ) + re_hash = re.compile(f"({BLOCK_HASH_REGEX})") def __init__(self, number: int, sha_hash: str) -> None: assert type(number) is int @@ -68,7 +66,7 @@ class BlockID: return cls(number, sha_hash) def __str__(self) -> str: - return "{0}-{1}".format(self.number, self.sha_hash) + return f"{self.number}-{self.sha_hash}" def __eq__(self, other: object) -> bool: if not isinstance(other, BlockID): @@ -116,6 +114,6 @@ def get_block_id(value: Union[str, BlockID, None]) -> BlockID: elif value is None: result = BlockID.empty() else: - raise TypeError("Cannot convert {0} to BlockID".format(type(value))) + raise TypeError(f"Cannot convert {type(value)} to BlockID") return result diff --git a/duniterpy/documents/certification.py b/duniterpy/documents/certification.py index 8ed73bcb5983b46ca9a6c8a3a12691da88f312cb..dfd5225d182e24e0b09ecc9c60f6c264addebd22 100644 --- a/duniterpy/documents/certification.py +++ b/duniterpy/documents/certification.py @@ -49,12 +49,8 @@ class Certification(Document): ) ) re_type = re.compile("Type: (Certification)") - re_issuer = re.compile( - "Issuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX) - ) - re_cert_block_id = re.compile( - "CertTimestamp: ({block_id_regex})\n".format(block_id_regex=BLOCK_ID_REGEX) - ) + re_issuer = re.compile(f"Issuer: ({PUBKEY_REGEX})\n") + re_cert_block_id = re.compile(f"CertTimestamp: ({BLOCK_ID_REGEX})\n") fields_parsers = { **Document.fields_parsers, @@ -153,7 +149,7 @@ class Certification(Document): """ cert_data = Certification.re_inline.match(inline) if cert_data is None: - raise MalformedDocumentError("Certification ({0})".format(inline)) + raise MalformedDocumentError(f"Certification ({inline})") pubkey_from = cert_data.group(1) pubkey_to = cert_data.group(2) block_number = int(cert_data.group(3)) @@ -235,6 +231,6 @@ CertTimestamp: {block_id} :return: """ - return "{0}:{1}:{2}:{3}".format( + return "{}:{}:{}:{}".format( self.pubkey_from, self.pubkey_to, self.block_id.number, self.signature ) diff --git a/duniterpy/documents/document.py b/duniterpy/documents/document.py index 0d16d7976da3843a2c1d6125af9dba07da975483..d81fcf15f51ecd79612f8e9d642c42a099d1c74c 100644 --- a/duniterpy/documents/document.py +++ b/duniterpy/documents/document.py @@ -35,7 +35,7 @@ class MalformedDocumentError(Exception): :param field_name: Name of the wrong field """ - super().__init__("Could not parse field {0}".format(field_name)) + super().__init__(f"Could not parse field {field_name}") # required to type hint cls in classmethod @@ -45,9 +45,7 @@ DocumentType = TypeVar("DocumentType", bound="Document") class Document: re_version = re.compile("Version: ([0-9]+)\n") re_currency = re.compile("Currency: ([^\n]+)\n") - re_signature = re.compile( - "({signature_regex})\n".format(signature_regex=SIGNATURE_REGEX) - ) + re_signature = re.compile(f"({SIGNATURE_REGEX})\n") fields_parsers: Dict[str, Pattern] = { "Version": re_version, diff --git a/duniterpy/documents/identity.py b/duniterpy/documents/identity.py index 50d3d57202092413ca322481779b551d004d449c..b473e936aeddc74a1205da0733ec3d9cfb212dbd 100644 --- a/duniterpy/documents/identity.py +++ b/duniterpy/documents/identity.py @@ -47,30 +47,16 @@ class Identity(Document): ) ) re_type = re.compile("Type: (Identity)") - re_issuer = re.compile( - "Issuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX) - ) - re_unique_id = re.compile("UniqueID: ({uid_regex})\n".format(uid_regex=UID_REGEX)) + re_issuer = re.compile(f"Issuer: ({PUBKEY_REGEX})\n") + re_unique_id = re.compile(f"UniqueID: ({UID_REGEX})\n") re_uid = re.compile("UID:([^\n]+)\n") - re_meta_ts = re.compile( - "META:TS:({block_id_regex})\n".format(block_id_regex=BLOCK_ID_REGEX) - ) - re_block_id = re.compile( - "Timestamp: ({block_id_regex})\n".format(block_id_regex=BLOCK_ID_REGEX) - ) + re_meta_ts = re.compile(f"META:TS:({BLOCK_ID_REGEX})\n") + re_block_id = re.compile(f"Timestamp: ({BLOCK_ID_REGEX})\n") - re_idty_issuer = re.compile( - "IdtyIssuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX) - ) - re_idty_unique_id = re.compile( - "IdtyUniqueID: ({uid_regex})\n".format(uid_regex=UID_REGEX) - ) - re_idty_block_id = re.compile( - "IdtyTimestamp: ({block_id_regex})\n".format(block_id_regex=BLOCK_ID_REGEX) - ) - re_idty_signature = re.compile( - "IdtySignature: ({signature_regex})\n".format(signature_regex=SIGNATURE_REGEX) - ) + re_idty_issuer = re.compile(f"IdtyIssuer: ({PUBKEY_REGEX})\n") + re_idty_unique_id = re.compile(f"IdtyUniqueID: ({UID_REGEX})\n") + re_idty_block_id = re.compile(f"IdtyTimestamp: ({BLOCK_ID_REGEX})\n") + re_idty_signature = re.compile(f"IdtySignature: ({SIGNATURE_REGEX})\n") fields_parsers = { **Document.fields_parsers, diff --git a/duniterpy/documents/membership.py b/duniterpy/documents/membership.py index 767fb0b4cdcf014cc6dadc23bd49c88e5b1d3458..f92dad8a627b9cfd16521df82bb879518c31bb7a 100644 --- a/duniterpy/documents/membership.py +++ b/duniterpy/documents/membership.py @@ -58,17 +58,11 @@ class Membership(Document): ) ) re_type = re.compile("Type: (Membership)") - re_issuer = re.compile( - "Issuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX) - ) - re_block = re.compile( - "Block: ({block_id_regex})\n".format(block_id_regex=BLOCK_ID_REGEX) - ) + re_issuer = re.compile(f"Issuer: ({PUBKEY_REGEX})\n") + re_block = re.compile(f"Block: ({BLOCK_ID_REGEX})\n") re_membership_type = re.compile("Membership: (IN|OUT)") re_userid = re.compile("UserID: ([^\n]+)\n") - re_certts = re.compile( - "CertTS: ({block_id_regex})\n".format(block_id_regex=BLOCK_ID_REGEX) - ) + re_certts = re.compile(f"CertTS: ({BLOCK_ID_REGEX})\n") fields_parsers = { **Document.fields_parsers, @@ -135,7 +129,7 @@ class Membership(Document): """ data = Membership.re_inline.match(inline) if data is None: - raise MalformedDocumentError("Inline membership ({0})".format(inline)) + raise MalformedDocumentError(f"Inline membership ({inline})") issuer = data.group(1) signature = data.group(2) membership_block_id = BlockID.from_str(data.group(3)) @@ -215,14 +209,14 @@ class Membership(Document): :return: """ - return """Version: {0} + return """Version: {} Type: Membership -Currency: {1} -Issuer: {2} -Block: {3} -Membership: {4} -UserID: {5} -CertTS: {6} +Currency: {} +Issuer: {} +Block: {} +Membership: {} +UserID: {} +CertTS: {} """.format( self.version, self.currency, @@ -238,7 +232,7 @@ CertTS: {6} Return inline string format of the Membership instance :return: """ - return "{0}:{1}:{2}:{3}:{4}".format( + return "{}:{}:{}:{}:{}".format( self.issuer, self.signature, self.membership_block_id, diff --git a/duniterpy/documents/peer.py b/duniterpy/documents/peer.py index c5dae7ab0911480bdb6d225a569762aa05e7de81..8431f39345132fa032709860ab6836981e1bb1d6 100644 --- a/duniterpy/documents/peer.py +++ b/duniterpy/documents/peer.py @@ -48,12 +48,8 @@ class Peer(Document): """ re_type = re.compile("Type: (Peer)") - re_pubkey = re.compile( - "PublicKey: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX) - ) - re_block = re.compile( - "Block: ([0-9]+-{block_hash_regex})\n".format(block_hash_regex=BLOCK_HASH_REGEX) - ) + re_pubkey = re.compile(f"PublicKey: ({PUBKEY_REGEX})\n") + re_block = re.compile(f"Block: ([0-9]+-{BLOCK_HASH_REGEX})\n") re_endpoints = re.compile("(Endpoints:)\n") fields_parsers = { @@ -145,18 +141,18 @@ class Peer(Document): :return: """ - doc = """Version: {0} + doc = """Version: {} Type: Peer -Currency: {1} -PublicKey: {2} -Block: {3} +Currency: {} +PublicKey: {} +Block: {} Endpoints: """.format( self.version, self.currency, self.pubkey, self.block_id ) for _endpoint in self.endpoints: - doc += "{0}\n".format(_endpoint.inline()) + doc += f"{_endpoint.inline()}\n" return doc diff --git a/duniterpy/documents/revocation.py b/duniterpy/documents/revocation.py index 44aa8bfa3266e2cc25fa556d5cebe53b87bc3eaa..70d2bdd4bb33c71d64c4e63ed6ad03139de1d8ef 100644 --- a/duniterpy/documents/revocation.py +++ b/duniterpy/documents/revocation.py @@ -45,16 +45,10 @@ class Revocation(Document): ) re_type = re.compile("Type: (Revocation)") - re_issuer = re.compile( - "Issuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX) - ) + re_issuer = re.compile(f"Issuer: ({PUBKEY_REGEX})\n") re_uniqueid = re.compile("IdtyUniqueID: ([^\n]+)\n") - re_block_id = re.compile( - "IdtyTimestamp: ({block_id_regex})\n".format(block_id_regex=BLOCK_ID_REGEX) - ) - re_idtysignature = re.compile( - "IdtySignature: ({signature_regex})\n".format(signature_regex=SIGNATURE_REGEX) - ) + re_block_id = re.compile(f"IdtyTimestamp: ({BLOCK_ID_REGEX})\n") + re_idtysignature = re.compile(f"IdtySignature: ({SIGNATURE_REGEX})\n") fields_parsers = { **Document.fields_parsers, @@ -165,7 +159,7 @@ class Revocation(Document): :return: """ - return "{0}:{1}".format(self.pubkey, self.signature) + return f"{self.pubkey}:{self.signature}" def raw(self) -> str: """ diff --git a/duniterpy/documents/transaction.py b/duniterpy/documents/transaction.py index ff0a45ea71b0c1e67d6dbb2e9cc297a328cf7ae6..9220f1da2f9d3b97ac8a109d0ac315192503e0de 100644 --- a/duniterpy/documents/transaction.py +++ b/duniterpy/documents/transaction.py @@ -152,7 +152,7 @@ class InputSource: :return: """ - return "{0}:{1}:{2}:{3}:{4}".format( + return "{}:{}:{}:{}:{}".format( self.amount, self.base, self.source, self.origin_id, self.index ) @@ -218,7 +218,7 @@ class OutputSource: :return: """ - return "{0}:{1}:{2}".format( + return "{}:{}:{}".format( self.amount, self.base, pypeg2.compose(self.condition, output.Condition) ) @@ -300,7 +300,7 @@ class SIGParameter: :return: """ - return "SIG({0})".format(self.index) + return f"SIG({self.index})" # required to type hint cls in classmethod @@ -359,7 +359,7 @@ class XHXParameter: :return: """ - return "XHX({0})".format(self.integer) + return f"XHX({self.integer})" # required to type hint cls in classmethod @@ -458,7 +458,7 @@ class Unlock: :return: """ - return "{0}:{1}".format( + return "{}:{}".format( self.index, " ".join([str(parameter) for parameter in self.parameters]) ) @@ -506,12 +506,8 @@ class Transaction(Document): re_header = re.compile( "TX:([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([01]):([0-9]+)\n" ) - re_compact_block_id = re.compile( - "({block_id_regex})\n".format(block_id_regex=BLOCK_ID_REGEX) - ) - re_block_id = re.compile( - "Blockstamp: ({block_id_regex})\n".format(block_id_regex=BLOCK_ID_REGEX) - ) + re_compact_block_id = re.compile(f"({BLOCK_ID_REGEX})\n") + re_block_id = re.compile(f"Blockstamp: ({BLOCK_ID_REGEX})\n") re_locktime = re.compile("Locktime: ([0-9]+)\n") re_issuers = re.compile("Issuers:\n") re_inputs = re.compile("Inputs:\n") @@ -519,7 +515,7 @@ class Transaction(Document): re_outputs = re.compile("Outputs:\n") re_compact_comment = re.compile("([^\n]+)\n") re_comment = re.compile("Comment: ([^\n]*)\n") - re_pubkey = re.compile("({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX)) + re_pubkey = re.compile(f"({PUBKEY_REGEX})\n") fields_parsers = { **Document.fields_parsers, @@ -633,7 +629,7 @@ class Transaction(Document): tx_data = tx_data.copy() tx_data["currency"] = currency for data_list in ("issuers", "outputs", "inputs", "unlocks", "signatures"): - tx_data["multiline_{0}".format(data_list)] = "\n".join(tx_data[data_list]) + tx_data[f"multiline_{data_list}"] = "\n".join(tx_data[data_list]) return cls.from_signed_raw( """Version: {version} Type: Transaction @@ -841,35 +837,35 @@ Comment: {comment} :return: """ - doc = """Version: {0} + doc = """Version: {} Type: Transaction -Currency: {1} +Currency: {} """.format( self.version, self.currency ) - doc += "Blockstamp: {0}\n".format(self.block_id) + doc += f"Blockstamp: {self.block_id}\n" - doc += "Locktime: {0}\n".format(self.locktime) + doc += f"Locktime: {self.locktime}\n" doc += "Issuers:\n" for p in self.issuers: - doc += "{0}\n".format(p) + doc += f"{p}\n" doc += "Inputs:\n" for i in self.inputs: - doc += "{0}\n".format(i.inline()) + doc += f"{i.inline()}\n" doc += "Unlocks:\n" for u in self.unlocks: - doc += "{0}\n".format(u.inline()) + doc += f"{u.inline()}\n" doc += "Outputs:\n" for o in self.outputs: - doc += "{0}\n".format(o.inline()) + doc += f"{o.inline()}\n" doc += "Comment: " - doc += "{0}\n".format(self.comment) + doc += f"{self.comment}\n" return doc @@ -887,7 +883,7 @@ Currency: {1} PUBLIC_KEY:AMOUNT ... COMMENT""" - doc = "TX:{0}:{1}:{2}:{3}:{4}:{5}:{6}\n".format( + doc = "TX:{}:{}:{}:{}:{}:{}:{}\n".format( self.version, len(self.issuers), len(self.inputs), @@ -896,20 +892,20 @@ Currency: {1} "1" if self.comment != "" else "0", self.locktime, ) - doc += "{0}\n".format(self.block_id) + doc += f"{self.block_id}\n" for pubkey in self.issuers: - doc += "{0}\n".format(pubkey) + doc += f"{pubkey}\n" for i in self.inputs: - doc += "{0}\n".format(i.inline()) + doc += f"{i.inline()}\n" for u in self.unlocks: - doc += "{0}\n".format(u.inline()) + doc += f"{u.inline()}\n" for o in self.outputs: - doc += "{0}\n".format(o.inline()) + doc += f"{o.inline()}\n" if self.comment != "": - doc += "{0}\n".format(self.comment) + doc += f"{self.comment}\n" for signature in self.signatures: - doc += "{0}\n".format(signature) + doc += f"{signature}\n" return doc diff --git a/duniterpy/documents/ws2p/heads.py b/duniterpy/documents/ws2p/heads.py index fc79f48c6bc05a81aac142acc713f525012b49e6..15e8314148a1659442f3a4593580bd62bf679bf2 100644 --- a/duniterpy/documents/ws2p/heads.py +++ b/duniterpy/documents/ws2p/heads.py @@ -73,7 +73,7 @@ class Head: raise MalformedDocumentError("Head") from AttributeError def __str__(self) -> str: - return "HEAD" if self.version == 0 else "HEAD:{}".format(str(self.version)) + return "HEAD" if self.version == 0 else f"HEAD:{str(self.version)}" @attr.s() @@ -124,7 +124,7 @@ class HeadV0(Head): ), ) ) - return "{0}:{1}".format(str(self.api), ":".join(values)) + return "{}:{}".format(str(self.api), ":".join(values)) def check_signature(self, pubkey: str) -> bool: """ diff --git a/duniterpy/grammars/output.py b/duniterpy/grammars/output.py index 39642772a2a0a778899aa32ea3914066f46500b4..11bbfa13234c26faa2ea83f04cccf6cd43cc9b8e 100644 --- a/duniterpy/grammars/output.py +++ b/duniterpy/grammars/output.py @@ -101,7 +101,7 @@ class SIG: :param attr_of: Attribute of... :return: """ - return "SIG({0})".format(self.pubkey) + return f"SIG({self.pubkey})" # required to type hint cls in classmethod @@ -160,7 +160,7 @@ class CSV: :param grammar: Grammar :param attr_of: Attribute of... """ - return "CSV({0})".format(self.time) + return f"CSV({self.time})" # required to type hint cls in classmethod @@ -219,7 +219,7 @@ class CLTV: :param grammar: Grammar :param attr_of: Attribute of... """ - return "CLTV({0})".format(self.timestamp) + return f"CLTV({self.timestamp})" # required to type hint cls in classmethod @@ -278,7 +278,7 @@ class XHX: :param grammar: Grammar :param attr_of: Attribute of... """ - return "XHX({0})".format(self.sha_hash) + return f"XHX({self.sha_hash})" # required to type hint cls in classmethod @@ -314,7 +314,7 @@ class Operator(Keyword): :param grammar: Grammar :param attr_of: Attribute of... """ - return "{0}".format(self.name) + return f"{self.name}" # required to type hint cls in classmethod @@ -391,7 +391,7 @@ class Condition: :param attr_of: Attribute of... """ if type(self.left) is Condition: - left = "({0})".format( + left = "({})".format( parser.compose(self.left, grammar=grammar, attr_of=attr_of) ) else: @@ -400,13 +400,13 @@ class Condition: if getattr(self, "op", None): if type(self.right) is Condition: - right = "({0})".format( + right = "({})".format( parser.compose(self.right, grammar=grammar, attr_of=attr_of) ) else: right = parser.compose(self.right, grammar=grammar, attr_of=attr_of) op = parser.compose(self.op, grammar=grammar, attr_of=attr_of) - result = "{0} {1} {2}".format(left, op, right) + result = f"{left} {op} {right}" else: result = left return result diff --git a/duniterpy/key/ascii_armor.py b/duniterpy/key/ascii_armor.py index db031dbde31fc4f6bf5b4c9c6a0c5f6547a4d88d..bd942bd211604db9531e78a5881dc2292942c510 100644 --- a/duniterpy/key/ascii_armor.py +++ b/duniterpy/key/ascii_armor.py @@ -171,7 +171,7 @@ class AsciiArmor: :param text: Text to clean up :return: """ - clean_text = str() + clean_text = "" for line in text.splitlines(True): # remove trailing spaces (0x20) and tabs (0x09) @@ -187,7 +187,7 @@ class AsciiArmor: :param text: Text to dash-escape :return: """ - dash_escaped_text = str() + dash_escaped_text = "" for line in text.splitlines(True): # add dash '-' (0x2D) and space ' ' (0x20) as prefix @@ -203,7 +203,7 @@ class AsciiArmor: :param dash_escaped_line: Dash escaped text line :return: """ - text = str() + text = "" regex_dash_escape_prefix = re.compile("^" + DASH_ESCAPE_PREFIX) # if prefixed by a dash escape prefix... if regex_dash_escape_prefix.match(dash_escaped_line): @@ -219,7 +219,7 @@ class AsciiArmor: :return: """ - return "Version: {version}".format(version=VERSION_FIELD_VALUE) + return f"Version: {VERSION_FIELD_VALUE}" @staticmethod def _get_comment_field(comment: str) -> str: @@ -229,7 +229,7 @@ class AsciiArmor: :param comment: Comment text :return: """ - return "Comment: {comment}".format(comment=comment) + return f"Comment: {comment}" @staticmethod def _get_signature_block( diff --git a/duniterpy/key/crc_pubkey.py b/duniterpy/key/crc_pubkey.py index 498e2a1531a7c3861c1554eccdf88d613deff158..fdec9b40d5fee38cabebbe0fec7c3923342a6849 100644 --- a/duniterpy/key/crc_pubkey.py +++ b/duniterpy/key/crc_pubkey.py @@ -31,9 +31,7 @@ class CRCPubkey: Class to implement a crc on a pubkey """ - re_crc_pubkey = re.compile( - "({pubkey_regex}):([A-Za-z0-9]{{3}})".format(pubkey_regex=PUBKEY_REGEX) - ) + re_crc_pubkey = re.compile(f"({PUBKEY_REGEX}):([A-Za-z0-9]{{3}})") def __init__(self, pubkey: str, crc: str) -> None: """ @@ -55,7 +53,7 @@ class CRCPubkey: """ data = CRCPubkey.re_crc_pubkey.match(crc_pubkey) if data is None: - raise Exception("Could not parse CRC public key {0}".format(crc_pubkey)) + raise Exception(f"Could not parse CRC public key {crc_pubkey}") pubkey = data.group(1) crc = data.group(2) return cls(pubkey, crc) @@ -89,4 +87,4 @@ class CRCPubkey: Return string representation of instance :return: """ - return "{:}:{:}".format(self.pubkey, self.crc) + return f"{self.pubkey}:{self.crc}" diff --git a/duniterpy/key/signing_key.py b/duniterpy/key/signing_key.py index 2600fce71265ec785e5112489743572049faa2d8..84fa05d9b666b2f6e3d1f42a733e8e8de63c63dc 100644 --- a/duniterpy/key/signing_key.py +++ b/duniterpy/key/signing_key.py @@ -89,7 +89,7 @@ class SigningKey(libnacl.sign.Signer): :return: """ # capture credentials from file - with open(path, "r") as fh: + with open(path) as fh: lines = fh.readlines() assert len(lines) > 1 salt = lines[0].strip() @@ -114,7 +114,7 @@ class SigningKey(libnacl.sign.Signer): :param str path: Hexadecimal seed file path """ - with open(path, "r") as fh: + with open(path) as fh: seedhex = fh.read() return SigningKey.from_seedhex(seedhex) @@ -174,7 +174,7 @@ class SigningKey(libnacl.sign.Signer): :param path: Path to WIF file """ - with open(path, "r") as fh: + with open(path) as fh: pubsec_content = fh.read() # line patterns @@ -235,7 +235,7 @@ sec: {signkey}""".format( :param path: Path to WIF of EWIF file :param password: Password needed for EWIF file """ - with open(path, "r") as fh: + with open(path) as fh: wif_content = fh.read() # check data field @@ -278,7 +278,7 @@ sec: {signkey}""".format( :param path: Path to WIF file """ - with open(path, "r") as fh: + with open(path) as fh: wif_content = fh.read() # check data field @@ -356,7 +356,7 @@ Data: {data}""".format( :param path: Path to EWIF file :param password: Password of the encrypted seed """ - with open(path, "r") as fh: + with open(path) as fh: wif_content = fh.read() # check data field @@ -488,7 +488,7 @@ Data: {data}""".format( :param path: Path to Scuttlebutt secret file """ - with open(path, "r") as fh: + with open(path) as fh: ssb_content = fh.read() # check data field diff --git a/examples/listen_ws2p.py b/examples/listen_ws2p.py index d45a84697f4c65e6846c29dbfb7267fc71c9669e..b4bf30160af1798276d06088bca4750e01a19464 100644 --- a/examples/listen_ws2p.py +++ b/examples/listen_ws2p.py @@ -94,7 +94,7 @@ def listen_ws2p(): print("Connection closed.") except jsonschema.ValidationError as e: - print("{:}:{:}".format(str(e.__class__.__name__), str(e))) + print(f"{str(e.__class__.__name__)}:{str(e)}") if __name__ == "__main__": diff --git a/examples/load_cleartext_ascii_armor_message.py b/examples/load_cleartext_ascii_armor_message.py index 0e607c60daba962d6e934d930ee767528006b3cd..65d6f9a449c088ad58c9e8d9a8003169daec3409 100644 --- a/examples/load_cleartext_ascii_armor_message.py +++ b/examples/load_cleartext_ascii_armor_message.py @@ -27,11 +27,11 @@ def load_cleartext_ascii_armor_message(): pubkeyBase58 = input("Enter public key of the message issuer: ") # Load cleartext ascii armor message from a file - with open(CLEARTEXT_AA_MESSAGE_PATH, "r") as file_handler: + with open(CLEARTEXT_AA_MESSAGE_PATH) as file_handler: ascii_armor_block = file_handler.read() print( - "Cleartext Ascii Armor Message loaded from file ./{0}".format( + "Cleartext Ascii Armor Message loaded from file ./{}".format( CLEARTEXT_AA_MESSAGE_PATH ) ) diff --git a/examples/load_credentials_file.py b/examples/load_credentials_file.py index e4dec58ff5c3621674dcf58a3dced5ed1ec80859..b20ad93b88493382620daf817e7dd27aa03630a6 100644 --- a/examples/load_credentials_file.py +++ b/examples/load_credentials_file.py @@ -33,7 +33,7 @@ def load_credentials_file(signing_key_instance=None): ) # type: SigningKey # print pubkey - print("Public key from credentials file: {}".format(signing_key_instance.pubkey)) + print(f"Public key from credentials file: {signing_key_instance.pubkey}") if __name__ == "__main__": diff --git a/examples/load_encrypted_ascii_armor_message.py b/examples/load_encrypted_ascii_armor_message.py index e247608482ef25094571b9d81ac52fd41b755525..fbf2eeb3bafa21feaa2cfa4c9f92b232fee50332 100644 --- a/examples/load_encrypted_ascii_armor_message.py +++ b/examples/load_encrypted_ascii_armor_message.py @@ -38,11 +38,11 @@ def load_encrypted_ascii_armor_message(): signing_key = SigningKey.from_credentials(salt, password) # Load ascii armor encrypted message from a file - with open(ENCRYPTED_AA_MESSAGE_PATH, "r") as file_handler: + with open(ENCRYPTED_AA_MESSAGE_PATH) as file_handler: ascii_armor_block = file_handler.read() print( - "Encrypted Ascii Armor Message loaded from file {0}".format( + "Encrypted Ascii Armor Message loaded from file {}".format( ENCRYPTED_AA_MESSAGE_PATH ) ) diff --git a/examples/load_scuttlebutt_file.py b/examples/load_scuttlebutt_file.py index bc07090baaa747104fa46914cb3be789edf37fc5..43903adb8f3939427f7507b68eccbbd836381c17 100644 --- a/examples/load_scuttlebutt_file.py +++ b/examples/load_scuttlebutt_file.py @@ -33,7 +33,7 @@ def load_scuttlebutt_file(signing_key_insance=None): ) # type: SigningKey # print pubkey - print("Public key from scuttlebutt file: {}".format(signing_key_instance.pubkey)) + print(f"Public key from scuttlebutt file: {signing_key_instance.pubkey}") if __name__ == "__main__": diff --git a/examples/request_data_elasticsearch.py b/examples/request_data_elasticsearch.py index 98dcb1ddfc00ac0f5e40dbe754ac90ce7d6e3081..17e8ccc904147fe26a624568612920aea94e4589 100644 --- a/examples/request_data_elasticsearch.py +++ b/examples/request_data_elasticsearch.py @@ -56,8 +56,8 @@ def request_data_elasticsearch(): pubkey = input("\nEnter a public key to get the user profile: ") # Get the profil of a public key (direct REST GET request) - print("\nGET user/profile/{0}/_source:".format(pubkey)) - response = client.get("user/profile/{0}/_source".format(pubkey.strip(" \n"))) + print(f"\nGET user/profile/{pubkey}/_source:") + response = client.get("user/profile/{}/_source".format(pubkey.strip(" \n"))) print(response) diff --git a/examples/request_web_socket_block.py b/examples/request_web_socket_block.py index a9df4e019887150553f1496d6a1eabe843982a9f..0c4009f8887948013b215b243266d88831adc507 100644 --- a/examples/request_web_socket_block.py +++ b/examples/request_web_socket_block.py @@ -55,7 +55,7 @@ def request_web_socket_block(): print(json.dumps(data, indent=2)) except jsonschema.ValidationError as e: - print("{:}:{:}".format(str(e.__class__.__name__), str(e))) + print(f"{str(e.__class__.__name__)}:{str(e)}") if __name__ == "__main__": diff --git a/examples/request_ws2p.py b/examples/request_ws2p.py index d4b22b4cb616efc1c2c855bf2a5ba68eaef86cef..28280e343140620f7ccaf9b09e7128e8f4102bab 100644 --- a/examples/request_ws2p.py +++ b/examples/request_ws2p.py @@ -162,7 +162,7 @@ def request_ws2p(): print("Response: " + json.dumps(response, indent=2)) except jsonschema.ValidationError as e: - print("{:}:{:}".format(str(e.__class__.__name__), str(e))) + print(f"{str(e.__class__.__name__)}:{str(e)}") if __name__ == "__main__": diff --git a/examples/save_and_load_private_key_file.py b/examples/save_and_load_private_key_file.py index 95adb9f06bc72be03e2eadee4ef30c57442ea5e0..f443922255ae18d8d5b4fa934adb9bb8f81b1a9b 100644 --- a/examples/save_and_load_private_key_file.py +++ b/examples/save_and_load_private_key_file.py @@ -59,9 +59,7 @@ def save_and_load_private_key_file(): signer.save_private_key(PRIVATE_KEYS_FILE_PATH) # document saved - print( - "Private keys for public key %s saved in %s" % (pubkey, PRIVATE_KEYS_FILE_PATH) - ) + print(f"Private keys for public key {pubkey} saved in {PRIVATE_KEYS_FILE_PATH}") # load private keys from file loaded_signer = SigningKey.from_private_key( diff --git a/examples/save_and_load_private_key_file_ewif.py b/examples/save_and_load_private_key_file_ewif.py index 07e23157c05f2d679143e16307bdc4ffc7fdea9c..5f2b3d55eaf713955a416c4f9b9e7dfdfbff6b1b 100644 --- a/examples/save_and_load_private_key_file_ewif.py +++ b/examples/save_and_load_private_key_file_ewif.py @@ -79,7 +79,7 @@ def save_and_load_private_key_file_ewif(): % (loaded_signer.pubkey, PRIVATE_KEY_FILE_PATH) ) - except IOError as error: + except OSError as error: print(error) return diff --git a/examples/save_and_load_private_key_file_pubsec.py b/examples/save_and_load_private_key_file_pubsec.py index 701f235ea9b715f5a634b6b16dbf96df16b6c608..8a11df657034924e37914966e11eac1e8a712f9c 100644 --- a/examples/save_and_load_private_key_file_pubsec.py +++ b/examples/save_and_load_private_key_file_pubsec.py @@ -74,7 +74,7 @@ def save_and_load_private_key_file_pubsec(): % (loaded_signer.pubkey, PRIVATE_KEY_FILE_PATH) ) - except IOError as error: + except OSError as error: print(error) return diff --git a/examples/save_and_load_private_key_file_wif.py b/examples/save_and_load_private_key_file_wif.py index 78c218c0172ef0601ec4b43bacad3cad9a5f8068..c3e2147ebe27c0c11058d9d3ed06b4199cda33c8 100644 --- a/examples/save_and_load_private_key_file_wif.py +++ b/examples/save_and_load_private_key_file_wif.py @@ -76,7 +76,7 @@ def save_and_load_private_key_file_wif(): % (loaded_signer.pubkey, PRIVATE_KEY_FILE_PATH) ) - except IOError as error: + except OSError as error: print(error) return diff --git a/examples/save_binary_encrypted_message.py b/examples/save_binary_encrypted_message.py index 3075d251c35c6cb25fa76db7c72a56dcf982d91e..a5159ab5c64919f16d570a69eb9bcbdb328362c4 100644 --- a/examples/save_binary_encrypted_message.py +++ b/examples/save_binary_encrypted_message.py @@ -37,7 +37,7 @@ def save_binary_encrypted_message(): with open(ENCRYPTED_MESSAGE_FILENAME, "wb") as file_handler: file_handler.write(encrypted_message) - print("Encrypted message saved in file ./{0}".format(ENCRYPTED_MESSAGE_FILENAME)) + print(f"Encrypted message saved in file ./{ENCRYPTED_MESSAGE_FILENAME}") if __name__ == "__main__": diff --git a/examples/save_binary_signed_message.py b/examples/save_binary_signed_message.py index 37e5b9b8961ce5c5b12f4b95af7ad7372b062f20..ae7b5020729d8f61dd6df0c6f369cc2802ca0074 100644 --- a/examples/save_binary_signed_message.py +++ b/examples/save_binary_signed_message.py @@ -55,7 +55,7 @@ def save_binary_signed_message(): with open(SIGNED_MESSAGE_FILENAME, "wb") as file_handler: file_handler.write(signed_message) - print("Signed message saved in file ./{0}".format(SIGNED_MESSAGE_FILENAME)) + print(f"Signed message saved in file ./{SIGNED_MESSAGE_FILENAME}") if __name__ == "__main__": diff --git a/examples/save_cleartext_ascii_armor_message.py b/examples/save_cleartext_ascii_armor_message.py index 00f68ec65382a57a3dd4fbda4a856cb44da92b39..8a60fcbdc5dca3210a15f220b9605f75fbde98e9 100644 --- a/examples/save_cleartext_ascii_armor_message.py +++ b/examples/save_cleartext_ascii_armor_message.py @@ -40,9 +40,9 @@ def save_cleartext_ascii_armor_message(): print("Enter your message (Ctrl-D below last line to end):") message = sys.stdin.read() - print("Message signed by puplic key : {pubkey}".format(pubkey=signing_key.pubkey)) + print(f"Message signed by puplic key : {signing_key.pubkey}") - comment = "generated by Duniterpy {0}".format(__version__) + comment = f"generated by Duniterpy {__version__}" # Dash escape the message and sign it aa_cleartext_message = AsciiArmor.create( message, None, [signing_key], None, signatures_comment=comment @@ -53,7 +53,7 @@ def save_cleartext_ascii_armor_message(): file_handler.write(aa_cleartext_message) print( - "Cleartext Ascii Armor Message saved in file ./{0}".format( + "Cleartext Ascii Armor Message saved in file ./{}".format( CLEARTEXT_AA_MESSAGE_PATH ) ) diff --git a/examples/save_encrypted_ascii_armor_message.py b/examples/save_encrypted_ascii_armor_message.py index c464b019e094571db3b92ab259962488f797b1d2..e055fc8637ee2cbf101b078bf9be9a2e8c9d21f3 100644 --- a/examples/save_encrypted_ascii_armor_message.py +++ b/examples/save_encrypted_ascii_armor_message.py @@ -41,9 +41,9 @@ def save_encrypted_ascii_armor_message(): # Enter the message message = input("Enter your message: ") - print("Message signed by puplic key : {pubkey}".format(pubkey=signing_key.pubkey)) + print(f"Message signed by puplic key : {signing_key.pubkey}") - comment = "generated by Duniterpy {0}".format(__version__) + comment = f"generated by Duniterpy {__version__}" # Encrypt the message, only the recipient secret key will be able to decrypt the message encrypted_message = AsciiArmor.create( message, @@ -58,7 +58,7 @@ def save_encrypted_ascii_armor_message(): file_handler.write(encrypted_message) print( - "Encrypted Ascii Armor Message saved in file {0}".format( + "Encrypted Ascii Armor Message saved in file {}".format( ENCRYPTED_AA_MESSAGE_PATH ) ) diff --git a/examples/save_revoke_document.py b/examples/save_revoke_document.py index b34325f6e49e542aea06d8701b6bd76f82661c09..b66773b821f3b047eb0c520946a9c25d43801cab 100644 --- a/examples/save_revoke_document.py +++ b/examples/save_revoke_document.py @@ -120,7 +120,7 @@ def save_revoke_document(): # create our Identity document to sign the revocation document identity = get_identity_document(client, current_block, pubkey) if identity is None: - print("Identity not found for pubkey {0}".format(pubkey)) + print(f"Identity not found for pubkey {pubkey}") # Close client aiohttp session return diff --git a/examples/send_certification.py b/examples/send_certification.py index f9a41b2c8d674da56fbcc1f4f8decca99a3d5d7f..c804028fc9730cfd813f7640d8f64d831620b83c 100644 --- a/examples/send_certification.py +++ b/examples/send_certification.py @@ -103,7 +103,7 @@ def send_certification(): # create our Identity document to sign the Certification document identity = get_identity_document(client, current_block, pubkey_to) if identity is None: - print("Identity not found for pubkey {0}".format(pubkey_to)) + print(f"Identity not found for pubkey {pubkey_to}") # Close client aiohttp session return diff --git a/examples/send_transaction.py b/examples/send_transaction.py index afa6ab3c1efbd05db25e7574d39f941f887ab5b3..e9c8b53c4c6c840f846381d098003d5bf86a7239 100644 --- a/examples/send_transaction.py +++ b/examples/send_transaction.py @@ -85,7 +85,7 @@ def get_transaction_document( OutputSource( amount=source["amount"], base=source["base"], - condition="SIG({0})".format(to_pubkey), + condition=f"SIG({to_pubkey})", ) ] diff --git a/tests/key/test_signing_key.py b/tests/key/test_signing_key.py index 16aed9d03f317e53c450cbc6d82b5274503f6c0f..3bfbb9005b8ae51ac7f968f15c8bda030f46afe8 100644 --- a/tests/key/test_signing_key.py +++ b/tests/key/test_signing_key.py @@ -99,7 +99,7 @@ class TestSigningKey(unittest.TestCase): # create a dummy credentials file with open(TEST_FILE_PATH, "w") as fh: - fh.write("{}\n{}\n".format(salt, password)) + fh.write(f"{salt}\n{password}\n") # same key from credentials sign_key_test = SigningKey.from_credentials(salt, password)