Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
f528e44c
Commit
f528e44c
authored
2 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[mypy]
#163
: Add type annotation on tools and blockchain_tools
parent
7eedeb94
No related branches found
No related tags found
1 merge request
!214
#163: Introduce mypy
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
silkaj/blockchain_tools.py
+4
-3
4 additions, 3 deletions
silkaj/blockchain_tools.py
silkaj/tools.py
+3
-4
3 additions, 4 deletions
silkaj/tools.py
with
7 additions
and
7 deletions
silkaj/blockchain_tools.py
+
4
−
3
View file @
f528e44c
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
import
functools
import
functools
from
typing
import
Dict
from
duniterpy.api.bma
import
blockchain
from
duniterpy.api.bma
import
blockchain
...
@@ -21,17 +22,17 @@ from silkaj.network_tools import client_instance
...
@@ -21,17 +22,17 @@ from silkaj.network_tools import client_instance
@functools.lru_cache
(
maxsize
=
1
)
@functools.lru_cache
(
maxsize
=
1
)
def
get_blockchain_parameters
():
def
get_blockchain_parameters
()
->
Dict
:
client
=
client_instance
()
client
=
client_instance
()
return
client
(
blockchain
.
parameters
)
return
client
(
blockchain
.
parameters
)
@functools.lru_cache
(
maxsize
=
1
)
@functools.lru_cache
(
maxsize
=
1
)
def
get_head_block
():
def
get_head_block
()
->
Dict
:
client
=
client_instance
()
client
=
client_instance
()
return
client
(
blockchain
.
current
)
return
client
(
blockchain
.
current
)
@functools.lru_cache
(
maxsize
=
1
)
@functools.lru_cache
(
maxsize
=
1
)
def
get_currency
():
def
get_currency
()
->
str
:
return
get_head_block
()[
"
currency
"
]
return
get_head_block
()[
"
currency
"
]
This diff is collapsed.
Click to expand it.
silkaj/tools.py
+
3
−
4
View file @
f528e44c
...
@@ -21,14 +21,13 @@ from silkaj.constants import FAILURE_EXIT_STATUS, G1_SYMBOL, GTEST_SYMBOL
...
@@ -21,14 +21,13 @@ from silkaj.constants import FAILURE_EXIT_STATUS, G1_SYMBOL, GTEST_SYMBOL
@functools.lru_cache
(
maxsize
=
1
)
@functools.lru_cache
(
maxsize
=
1
)
def
get_currency_symbol
():
def
get_currency_symbol
()
->
str
:
params
=
get_blockchain_parameters
()
params
=
get_blockchain_parameters
()
if
params
[
"
currency
"
]
==
"
g1
"
:
if
params
[
"
currency
"
]
==
"
g1
"
:
return
G1_SYMBOL
return
G1_SYMBOL
elif
params
[
"
currency
"
]
==
"
g1-test
"
:
return
GTEST_SYMBOL
return
GTEST_SYMBOL
def
message_exit
(
message
)
:
def
message_exit
(
message
:
str
)
->
None
:
print
(
message
)
print
(
message
)
exit
(
FAILURE_EXIT_STATUS
)
exit
(
FAILURE_EXIT_STATUS
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment