From a0891886648c96fefb7e45327712b44da15fab24 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 23 Jan 2023 09:29:17 +0000 Subject: [PATCH] add pyright to the project (#1367) * add pyright to project + bump prettier to latest * reformat to match the latest prettier rules --- Makefile | 3 ++ .../copilot/templates/copilot/compose.html | 5 +-- .../gerty/templates/gerty/gerty.html | 20 ++++------ .../gerty/templates/gerty/index.html | 4 +- lnbits/extensions/jukebox/static/js/index.js | 3 +- .../templates/lnurldevice/index.html | 11 +++--- .../market/templates/market/index.html | 5 +-- .../satspay/templates/satspay/index.html | 3 +- .../extensions/smtp/templates/smtp/index.html | 11 +++--- .../templates/subdomains/index.html | 5 +-- .../components/wallet-list/wallet-list.js | 11 +++--- package-lock.json | 39 +++++++++++++++---- package.json | 3 +- pyproject.toml | 8 ++++ 14 files changed, 82 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index ebf2a8729..22d79f113 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,9 @@ check: mypy checkprettier checkisort checkblack prettier: $(shell find lnbits -name "*.js" -o -name ".html") ./node_modules/.bin/prettier --write lnbits/static/js/*.js lnbits/core/static/js/*.js lnbits/extensions/*/templates/*/*.html ./lnbits/core/templates/core/*.html lnbits/templates/*.html lnbits/extensions/*/static/js/*.js lnbits/extensions/*/static/components/*/*.js lnbits/extensions/*/static/components/*/*.html +pyright: + ./node_modules/.bin/pyright + black: poetry run black . diff --git a/lnbits/extensions/copilot/templates/copilot/compose.html b/lnbits/extensions/copilot/templates/copilot/compose.html index 41745f0a4..2ec4c4f72 100644 --- a/lnbits/extensions/copilot/templates/copilot/compose.html +++ b/lnbits/extensions/copilot/templates/copilot/compose.html @@ -108,9 +108,8 @@ }, methods: { showNotif: function (userMessage) { - var colour = this.colours[ - Math.floor(Math.random() * this.colours.length) - ] + var colour = + this.colours[Math.floor(Math.random() * this.colours.length)] this.$q.notify({ color: colour, icon: 'chat_bubble_outline', diff --git a/lnbits/extensions/gerty/templates/gerty/gerty.html b/lnbits/extensions/gerty/templates/gerty/gerty.html index 899942c1e..48122c998 100644 --- a/lnbits/extensions/gerty/templates/gerty/gerty.html +++ b/lnbits/extensions/gerty/templates/gerty/gerty.html @@ -224,21 +224,17 @@ gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %} this.gertyname = this.gerty[i].settings.name } if (this.gerty[i].screen.group == 'fun_satoshi_quotes') { - this.fun_satoshi_quotes['quote'] = this.gerty[ - i - ].screen.areas[0][0].value - this.fun_satoshi_quotes['date'] = this.gerty[ - i - ].screen.areas[0][1].value + this.fun_satoshi_quotes['quote'] = + this.gerty[i].screen.areas[0][0].value + this.fun_satoshi_quotes['date'] = + this.gerty[i].screen.areas[0][1].value this.gertyname = this.gerty[i].settings.name } if (this.gerty[i].screen.group == 'fun_exchange_market_rate') { - this.fun_exchange_market_rate['unit'] = this.gerty[ - i - ].screen.areas[0][0].value - this.fun_exchange_market_rate['amount'] = this.gerty[ - i - ].screen.areas[0][1].value + this.fun_exchange_market_rate['unit'] = + this.gerty[i].screen.areas[0][0].value + this.fun_exchange_market_rate['amount'] = + this.gerty[i].screen.areas[0][1].value this.gertyname = this.gerty[i].settings.name } } diff --git a/lnbits/extensions/gerty/templates/gerty/index.html b/lnbits/extensions/gerty/templates/gerty/index.html index e9225bc20..b5eb42215 100644 --- a/lnbits/extensions/gerty/templates/gerty/index.html +++ b/lnbits/extensions/gerty/templates/gerty/index.html @@ -616,8 +616,8 @@ self.toggleStates.onchain self.formDialog.data.display_preferences.onchain_difficulty_retarget_date = self.toggleStates.onchain - self.formDialog.data.display_preferences.onchain_difficulty_blocks_remaining = !self - .toggleStates.onchain + self.formDialog.data.display_preferences.onchain_difficulty_blocks_remaining = + !self.toggleStates.onchain self.formDialog.data.display_preferences.onchain_difficulty_epoch_time_remaining = self.toggleStates.onchain self.formDialog.data.display_preferences.onchain_block_height = diff --git a/lnbits/extensions/jukebox/static/js/index.js b/lnbits/extensions/jukebox/static/js/index.js index fe724450a..1241b80e0 100644 --- a/lnbits/extensions/jukebox/static/js/index.js +++ b/lnbits/extensions/jukebox/static/js/index.js @@ -255,7 +255,8 @@ new Vue({ }, createJukebox() { self = this - self.jukeboxDialog.data.sp_playlists = self.jukeboxDialog.data.sp_playlists.join() + self.jukeboxDialog.data.sp_playlists = + self.jukeboxDialog.data.sp_playlists.join() self.updateDB() self.jukeboxDialog.show = false self.getJukeboxes() diff --git a/lnbits/extensions/lnurldevice/templates/lnurldevice/index.html b/lnbits/extensions/lnurldevice/templates/lnurldevice/index.html index 118183018..f308cc652 100644 --- a/lnbits/extensions/lnurldevice/templates/lnurldevice/index.html +++ b/lnbits/extensions/lnurldevice/templates/lnurldevice/index.html @@ -807,11 +807,12 @@ updatedData ) .then(function (response) { - self.lnurldeviceLinks = _.reject(self.lnurldeviceLinks, function ( - obj - ) { - return obj.id === updatedData.id - }) + self.lnurldeviceLinks = _.reject( + self.lnurldeviceLinks, + function (obj) { + return obj.id === updatedData.id + } + ) self.lnurldeviceLinks.push(maplnurldevice(response.data)) self.formDialoglnurldevice.show = false self.clearFormDialoglnurldevice() diff --git a/lnbits/extensions/market/templates/market/index.html b/lnbits/extensions/market/templates/market/index.html index 77e3acced..0f8fa78bb 100644 --- a/lnbits/extensions/market/templates/market/index.html +++ b/lnbits/extensions/market/templates/market/index.html @@ -803,9 +803,8 @@ self.productDialog.data = _.clone(link._data) if (self.productDialog.data.categories) { - self.productDialog.data.categories = self.productDialog.data.categories.split( - ',' - ) + self.productDialog.data.categories = + self.productDialog.data.categories.split(',') } if (self.productDialog.data.image.startsWith('data:')) { self.productDialog.url = false diff --git a/lnbits/extensions/satspay/templates/satspay/index.html b/lnbits/extensions/satspay/templates/satspay/index.html index 5a1c62f4d..74b3d2ccc 100644 --- a/lnbits/extensions/satspay/templates/satspay/index.html +++ b/lnbits/extensions/satspay/templates/satspay/index.html @@ -809,7 +809,8 @@ this.createTheme(wallet, data) }, sendFormDataCharge: function () { - this.formDialogCharge.data.custom_css = this.formDialogCharge.data.custom_css?.id + this.formDialogCharge.data.custom_css = + this.formDialogCharge.data.custom_css?.id const data = this.formDialogCharge.data const wallet = this.g.user.wallets[0].inkey data.amount = parseInt(data.amount) diff --git a/lnbits/extensions/smtp/templates/smtp/index.html b/lnbits/extensions/smtp/templates/smtp/index.html index c64cdcfa2..4b00cd082 100644 --- a/lnbits/extensions/smtp/templates/smtp/index.html +++ b/lnbits/extensions/smtp/templates/smtp/index.html @@ -574,11 +574,12 @@ .inkey ) .then(function (response) { - self.emailaddresses = _.reject(self.emailaddresses, function ( - obj - ) { - return obj.id == emailaddressId - }) + self.emailaddresses = _.reject( + self.emailaddresses, + function (obj) { + return obj.id == emailaddressId + } + ) }) .catch(function (error) { LNbits.utils.notifyApiError(error) diff --git a/lnbits/extensions/subdomains/templates/subdomains/index.html b/lnbits/extensions/subdomains/templates/subdomains/index.html index e8d8ec57d..a39773e71 100644 --- a/lnbits/extensions/subdomains/templates/subdomains/index.html +++ b/lnbits/extensions/subdomains/templates/subdomains/index.html @@ -484,9 +484,8 @@ var link = _.findWhere(this.domains, {id: formId}) console.log(link.id) this.domainDialog.data = _.clone(link) - this.domainDialog.data.allowed_record_types = link.allowed_record_types.split( - ', ' - ) + this.domainDialog.data.allowed_record_types = + link.allowed_record_types.split(', ') this.domainDialog.show = true }, updateDomain: function (wallet, data) { diff --git a/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.js b/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.js index 004f092ba..27d40ce97 100644 --- a/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.js +++ b/lnbits/extensions/watchonly/static/components/wallet-list/wallet-list.js @@ -174,11 +174,12 @@ async function walletList(path) { '/watchonly/api/v1/wallet/' + walletAccountId, this.adminkey ) - this.walletAccounts = _.reject(this.walletAccounts, function ( - obj - ) { - return obj.id === walletAccountId - }) + this.walletAccounts = _.reject( + this.walletAccounts, + function (obj) { + return obj.id === walletAccountId + } + ) await this.refreshWalletAccounts() } catch (error) { this.$q.notify({ diff --git a/package-lock.json b/package-lock.json index f2ff24bdd..37760cfc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,31 +1,54 @@ { - "name": "lnbits-legend", + "name": "lnbits", "lockfileVersion": 2, "requires": true, "packages": { "": { "devDependencies": { - "prettier": "2.1.1" + "prettier": "2.8.3", + "pyright": "1.1.289" } }, "node_modules/prettier": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz", - "integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz", + "integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==", "dev": true, "bin": { "prettier": "bin-prettier.js" }, "engines": { "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/pyright": { + "version": "1.1.289", + "resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.289.tgz", + "integrity": "sha512-fG3STxnwAt3i7bxbXUPJdYNFrcOWHLwCSEOySH2foUqtYdzWLcxDez0Kgl1X8LMQx0arMJ6HRkKghxfRD1/z6g==", + "dev": true, + "bin": { + "pyright": "index.js", + "pyright-langserver": "langserver.index.js" + }, + "engines": { + "node": ">=12.0.0" } } }, "dependencies": { "prettier": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz", - "integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz", + "integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==", + "dev": true + }, + "pyright": { + "version": "1.1.289", + "resolved": "https://registry.npmjs.org/pyright/-/pyright-1.1.289.tgz", + "integrity": "sha512-fG3STxnwAt3i7bxbXUPJdYNFrcOWHLwCSEOySH2foUqtYdzWLcxDez0Kgl1X8LMQx0arMJ6HRkKghxfRD1/z6g==", "dev": true } } diff --git a/package.json b/package.json index 19d34f128..de2a17915 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "devDependencies": { - "prettier": "2.1.1" + "prettier": "2.8.3", + "pyright": "1.1.289" } } diff --git a/pyproject.toml b/pyproject.toml index 23fe0dae1..da873a125 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,6 +86,14 @@ lnbits = "lnbits.server:main" [tool.isort] profile = "black" +[tool.pyright] +include = [ + "lnbits" +] +exclude = [ + "lnbits/wallets/lnd_grpc_files", +] + [tool.mypy] files = "lnbits" exclude = """(?x)(