Commit 8686b8ae authored by Vincent Texier's avatar Vincent Texier
Browse files

[enh] upgrade and freeze black formatter version

reformat code and tests
parent 05e47269
black
black==20.8b1
duniter-mirage>=0.1.50
mypy==0.770
pylint==2.4.4
......
......@@ -147,7 +147,11 @@ class Application(QObject):
self._logger.debug(
"Load root servers config file: {}".format(root_servers_config_path)
)
with open(root_servers_config_path, "r", encoding="utf-8",) as stream:
with open(
root_servers_config_path,
"r",
encoding="utf-8",
) as stream:
self.root_servers = yaml.load(stream, Loader=yaml.FullLoader)
def load_profile(self, profile_name):
......
......@@ -107,11 +107,13 @@ class IdentitiesProcessor:
)
if identity not in identities:
# Search same identity with empty blockstamp (incomplete)
same_with_empty_blockstamp = self._identities_repo.get_one(
currency=identity.currency,
uid=identity.uid,
pubkey=identity.pubkey,
blockstamp=BlockUID.empty(),
same_with_empty_blockstamp = (
self._identities_repo.get_one(
currency=identity.currency,
uid=identity.uid,
pubkey=identity.pubkey,
blockstamp=BlockUID.empty(),
)
)
# Same identity with empty blockstamp (incomplete) should not appears as duplicate
# Beware that identities in block 0 have empty blockstamps !
......
......@@ -49,7 +49,7 @@ class SourcesProcessor:
return sum([s.amount * (10 ** s.base) for s in sources])
def available(self, currency, pubkey):
""""
""" "
:param str currency: the currency of the sources
:param str pubkey: the owner of the sources
:rtype: list[sakia.data.entities.Source]
......
......@@ -79,8 +79,12 @@ states = {
(lambda tx, l: _broadcast_failure(tx, l), None, Transaction.REFUSED),
),
(Transaction.TO_SEND, ()): ((_is_locally_created, _drop, Transaction.DROPPED),),
(Transaction.AWAITING, (str, int,)): (
(_found_in_block, _be_validated, Transaction.VALIDATED),
),
(
Transaction.AWAITING,
(
str,
int,
),
): ((_found_in_block, _be_validated, Transaction.VALIDATED),),
(Transaction.REFUSED, ()): ((_is_locally_created, _drop, Transaction.DROPPED),),
}
......@@ -7,8 +7,7 @@ from ..entities import Blockchain, BlockchainParameters
@attr.s(frozen=True)
class BlockchainsRepo:
"""The repository for Blockchain entities.
"""
"""The repository for Blockchain entities."""
_conn = attr.ib() # :type sqlite3.Connection
_primary_keys = (attr.fields(Blockchain).currency,)
......
......@@ -5,8 +5,7 @@ from ..entities import Certification
@attr.s(frozen=True)
class CertificationsRepo:
"""The repository for Communities entities.
"""
"""The repository for Communities entities."""
_conn = attr.ib() # :type sqlite3.Connection
_primary_keys = (
......
......@@ -5,8 +5,7 @@ from ..entities import Dividend
@attr.s(frozen=True)
class DividendsRepo:
"""The repository for Communities entities.
"""
"""The repository for Communities entities."""
_conn = attr.ib() # :type sqlite3.Connection
_primary_keys = (
......
......@@ -7,8 +7,7 @@ from ..entities import Identity
@attr.s(frozen=True)
class IdentitiesRepo:
"""The repository for Identities entities.
"""
"""The repository for Identities entities."""
_conn = attr.ib() # :type sqlite3.Connection
_primary_keys = (
......
......@@ -6,8 +6,7 @@ from ..entities import Node
@attr.s(frozen=True)
class NodesRepo:
"""The repository for Communities entities.
"""
"""The repository for Communities entities."""
_conn = attr.ib() # :type sqlite3.Connection
_primary_keys = (attr.fields(Node).currency, attr.fields(Node).pubkey)
......
......@@ -5,8 +5,7 @@ from ..entities import Source
@attr.s(frozen=True)
class SourcesRepo:
"""The repository for Communities entities.
"""
"""The repository for Communities entities."""
_conn = attr.ib() # :type sqlite3.Connection
_primary_keys = (
......
......@@ -5,8 +5,7 @@ from ..entities import Transaction, Dividend
@attr.s(frozen=True)
class TransactionsRepo:
"""The repository for Communities entities.
"""
"""The repository for Communities entities."""
_conn = attr.ib() # :type sqlite3.Connection
_primary_keys = (
......
......@@ -146,7 +146,7 @@ class ConnectionConfigModel(QObject):
)
async def publish_selfcert(self, identity):
""""
""" "
Publish the self certification of the connection identity
"""
result = await self.app.documents_service.broadcast_identity(
......
......@@ -62,7 +62,16 @@ class WotScene(BaseScene):
@staticmethod
def center_pos(nb_certifiers, nb_certified, scale):
return 0, max(nb_certified, nb_certifiers,) / 2 * 0.12 * scale
return (
0,
max(
nb_certified,
nb_certifiers,
)
/ 2
* 0.12
* scale,
)
@staticmethod
def certifiers_partial_layout(nx_graph, center, scale=1):
......
......@@ -126,8 +126,10 @@ class IdentitiesFilterProxyModel(QSortFilterProxyModel):
font.setItalic(True)
return font
if role == Qt.DecorationRole and source_index.column() == IdentitiesTableModel.columns_ids.index(
"uid"
if (
role == Qt.DecorationRole
and source_index.column()
== IdentitiesTableModel.columns_ids.index("uid")
):
if status == STATUS_NOT_MEMBER:
return QIcon(":/icons/not_member")
......
......@@ -42,7 +42,9 @@ class NavigationModel(QObject):
"title": QCoreApplication.translate("NavigationModel", "Network"),
"icon": ":/icons/network_icon",
"component": "Network",
"dependencies": {"network_service": self.app.network_service,},
"dependencies": {
"network_service": self.app.network_service,
},
"misc": {},
"children": [],
},
......
......@@ -40,7 +40,9 @@ class NetworkController(QObject):
:param sakia.services.NetworkService network_service:
:return:
"""
view = NetworkView(parent.view,)
view = NetworkView(
parent.view,
)
model = NetworkModel(None, app, network_service)
txhistory = cls(parent, view, model)
model.setParent(txhistory)
......
......@@ -210,11 +210,13 @@ class TxHistoryController(QObject):
self._logger.error(str(e))
try:
new_dividends = await self.model.transactions_service.update_dividends_history(
pubkey,
self.view.table_history.model().ts_from,
self.view.table_history.model().ts_to,
new_tx,
new_dividends = (
await self.model.transactions_service.update_dividends_history(
pubkey,
self.view.table_history.model().ts_from,
self.view.table_history.model().ts_to,
new_tx,
)
)
self._logger.debug("Found {} new dividends".format(len(new_dividends)))
......
......@@ -421,7 +421,9 @@ class DocumentsService:
SIG.token(receiver),
Operator.token("||"),
Condition.token(
SIG.token(issuer), Operator.token("&&"), CSV.token(604800),
SIG.token(issuer),
Operator.token("&&"),
CSV.token(604800),
),
),
Condition,
......
......@@ -112,8 +112,10 @@ class IdentitiesService(QObject):
blockstamp = BlockUID(ms["blockNumber"], ms["blockHash"])
membership_data = ms
if membership_data:
identity.membership_timestamp = await self._blockchain_processor.timestamp(
self.currency, blockstamp.number
identity.membership_timestamp = (
await self._blockchain_processor.timestamp(
self.currency, blockstamp.number
)
)
identity.membership_buid = blockstamp
identity.membership_type = membership_data["membership"]
......@@ -199,8 +201,10 @@ class IdentitiesService(QObject):
certified[cert] = certified_idty
# We save connections pubkeys
if self.is_identity_of_connection(identity):
cert.timestamp = self._blockchain_processor.rounded_timestamp(
self.currency, cert.block
cert.timestamp = (
self._blockchain_processor.rounded_timestamp(
self.currency, cert.block
)
)
self._certs_processor.insert_or_update_certification(cert)
except errors.DuniterError as e:
......@@ -395,8 +399,10 @@ class IdentitiesService(QObject):
identity.blockstamp = block_uid(
identity_data["meta"]["timestamp"]
)
identity.timestamp = self._blockchain_processor.rounded_timestamp(
self.currency, identity.blockstamp.number
identity.timestamp = (
self._blockchain_processor.rounded_timestamp(
self.currency, identity.blockstamp.number
)
)
identity.outdistanced = identity_data["outdistanced"]
identity.written = identity_data["wasMember"]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment