mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
pyln: Add mypy typing exceptions for external dependencies
We don't control them, and starting to write type stubs for them is a different can of worms.
This commit is contained in:
committed by
Rusty Russell
parent
e13c435aca
commit
c498f949cc
@@ -25,7 +25,7 @@ check-pytest:
|
|||||||
pytest tests
|
pytest tests
|
||||||
|
|
||||||
check-mypy:
|
check-mypy:
|
||||||
mypy --namespace-packages tests pyln
|
MYPYPATH=$(PYTHONPATH) mypy --namespace-packages tests pyln
|
||||||
|
|
||||||
$(SDIST_FILE):
|
$(SDIST_FILE):
|
||||||
python3 setup.py sdist
|
python3 setup.py sdist
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
""" A bitcoind proxy that allows instrumentation and canned responses
|
""" A bitcoind proxy that allows instrumentation and canned responses
|
||||||
"""
|
"""
|
||||||
from flask import Flask, request
|
from flask import Flask, request
|
||||||
from bitcoin.rpc import JSONRPCError
|
from bitcoin.rpc import JSONRPCError # type: ignore
|
||||||
from bitcoin.rpc import RawProxy as BitcoinProxy
|
from bitcoin.rpc import RawProxy as BitcoinProxy # type: ignore
|
||||||
from cheroot.wsgi import Server
|
from cheroot.wsgi import Server # type: ignore
|
||||||
from cheroot.wsgi import PathInfoDispatcher
|
from cheroot.wsgi import PathInfoDispatcher # type: ignore
|
||||||
|
|
||||||
import decimal
|
import decimal
|
||||||
import flask
|
import flask
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
from ephemeral_port_reserve import reserve
|
from ephemeral_port_reserve import reserve # type: ignore
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import psycopg2
|
import psycopg2 # type: ignore
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
@@ -13,18 +13,19 @@ import sqlite3
|
|||||||
import string
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
from typing import Dict, List, Optional, Union
|
||||||
|
|
||||||
|
|
||||||
class Sqlite3Db(object):
|
class Sqlite3Db(object):
|
||||||
def __init__(self, path):
|
def __init__(self, path: str) -> None:
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
def get_dsn(self):
|
def get_dsn(self) -> None:
|
||||||
"""SQLite3 doesn't provide a DSN, resulting in no CLI-option.
|
"""SQLite3 doesn't provide a DSN, resulting in no CLI-option.
|
||||||
"""
|
"""
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def query(self, query):
|
def query(self, query: str) -> Union[List[Dict[str, Union[int, bytes]]], List[Dict[str, Optional[int]]], List[Dict[str, str]], List[Dict[str, Union[str, int]]], List[Dict[str, int]]]:
|
||||||
orig = os.path.join(self.path)
|
orig = os.path.join(self.path)
|
||||||
copy = self.path + ".copy"
|
copy = self.path + ".copy"
|
||||||
shutil.copyfile(orig, copy)
|
shutil.copyfile(orig, copy)
|
||||||
@@ -44,7 +45,7 @@ class Sqlite3Db(object):
|
|||||||
db.close()
|
db.close()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def execute(self, query):
|
def execute(self, query: str) -> None:
|
||||||
db = sqlite3.connect(self.path)
|
db = sqlite3.connect(self.path)
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
c.execute(query)
|
c.execute(query)
|
||||||
@@ -91,20 +92,20 @@ class PostgresDb(object):
|
|||||||
|
|
||||||
|
|
||||||
class SqliteDbProvider(object):
|
class SqliteDbProvider(object):
|
||||||
def __init__(self, directory):
|
def __init__(self, directory: str) -> None:
|
||||||
self.directory = directory
|
self.directory = directory
|
||||||
|
|
||||||
def start(self):
|
def start(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_db(self, node_directory, testname, node_id):
|
def get_db(self, node_directory: str, testname: str, node_id: int) -> Sqlite3Db:
|
||||||
path = os.path.join(
|
path = os.path.join(
|
||||||
node_directory,
|
node_directory,
|
||||||
'lightningd.sqlite3'
|
'lightningd.sqlite3'
|
||||||
)
|
)
|
||||||
return Sqlite3Db(path)
|
return Sqlite3Db(path)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
from bitcoin.core import COIN
|
from bitcoin.core import COIN # type: ignore
|
||||||
from bitcoin.rpc import RawProxy as BitcoinProxy
|
from bitcoin.rpc import RawProxy as BitcoinProxy # type: ignore
|
||||||
from pyln.client import RpcError
|
from pyln.client import RpcError
|
||||||
from pyln.testing.btcproxy import BitcoinRpcProxy
|
from pyln.testing.btcproxy import BitcoinRpcProxy
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from ephemeral_port_reserve import reserve
|
from ephemeral_port_reserve import reserve # type: ignore
|
||||||
from pyln.client import LightningRpc
|
from pyln.client import LightningRpc
|
||||||
from pyln.client import Millisatoshi
|
from pyln.client import Millisatoshi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user