add pyright to the project (#1367)

* add pyright to project + bump prettier to latest

* reformat to match the latest prettier rules
This commit is contained in:
Pavol Rusnak
2023-01-23 09:29:17 +00:00
committed by GitHub
parent 9693e5932b
commit a089188664
14 changed files with 82 additions and 49 deletions

View File

@@ -9,6 +9,9 @@ check: mypy checkprettier checkisort checkblack
prettier: $(shell find lnbits -name "*.js" -o -name ".html") 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 ./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: black:
poetry run black . poetry run black .

View File

@@ -108,9 +108,8 @@
}, },
methods: { methods: {
showNotif: function (userMessage) { showNotif: function (userMessage) {
var colour = this.colours[ var colour =
Math.floor(Math.random() * this.colours.length) this.colours[Math.floor(Math.random() * this.colours.length)]
]
this.$q.notify({ this.$q.notify({
color: colour, color: colour,
icon: 'chat_bubble_outline', icon: 'chat_bubble_outline',

View File

@@ -224,21 +224,17 @@ gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
this.gertyname = this.gerty[i].settings.name this.gertyname = this.gerty[i].settings.name
} }
if (this.gerty[i].screen.group == 'fun_satoshi_quotes') { if (this.gerty[i].screen.group == 'fun_satoshi_quotes') {
this.fun_satoshi_quotes['quote'] = this.gerty[ this.fun_satoshi_quotes['quote'] =
i this.gerty[i].screen.areas[0][0].value
].screen.areas[0][0].value this.fun_satoshi_quotes['date'] =
this.fun_satoshi_quotes['date'] = this.gerty[ this.gerty[i].screen.areas[0][1].value
i
].screen.areas[0][1].value
this.gertyname = this.gerty[i].settings.name this.gertyname = this.gerty[i].settings.name
} }
if (this.gerty[i].screen.group == 'fun_exchange_market_rate') { if (this.gerty[i].screen.group == 'fun_exchange_market_rate') {
this.fun_exchange_market_rate['unit'] = this.gerty[ this.fun_exchange_market_rate['unit'] =
i this.gerty[i].screen.areas[0][0].value
].screen.areas[0][0].value this.fun_exchange_market_rate['amount'] =
this.fun_exchange_market_rate['amount'] = this.gerty[ this.gerty[i].screen.areas[0][1].value
i
].screen.areas[0][1].value
this.gertyname = this.gerty[i].settings.name this.gertyname = this.gerty[i].settings.name
} }
} }

View File

@@ -616,8 +616,8 @@
self.toggleStates.onchain self.toggleStates.onchain
self.formDialog.data.display_preferences.onchain_difficulty_retarget_date = self.formDialog.data.display_preferences.onchain_difficulty_retarget_date =
self.toggleStates.onchain self.toggleStates.onchain
self.formDialog.data.display_preferences.onchain_difficulty_blocks_remaining = !self self.formDialog.data.display_preferences.onchain_difficulty_blocks_remaining =
.toggleStates.onchain !self.toggleStates.onchain
self.formDialog.data.display_preferences.onchain_difficulty_epoch_time_remaining = self.formDialog.data.display_preferences.onchain_difficulty_epoch_time_remaining =
self.toggleStates.onchain self.toggleStates.onchain
self.formDialog.data.display_preferences.onchain_block_height = self.formDialog.data.display_preferences.onchain_block_height =

View File

@@ -255,7 +255,8 @@ new Vue({
}, },
createJukebox() { createJukebox() {
self = this 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.updateDB()
self.jukeboxDialog.show = false self.jukeboxDialog.show = false
self.getJukeboxes() self.getJukeboxes()

View File

@@ -807,11 +807,12 @@
updatedData updatedData
) )
.then(function (response) { .then(function (response) {
self.lnurldeviceLinks = _.reject(self.lnurldeviceLinks, function ( self.lnurldeviceLinks = _.reject(
obj self.lnurldeviceLinks,
) { function (obj) {
return obj.id === updatedData.id return obj.id === updatedData.id
}) }
)
self.lnurldeviceLinks.push(maplnurldevice(response.data)) self.lnurldeviceLinks.push(maplnurldevice(response.data))
self.formDialoglnurldevice.show = false self.formDialoglnurldevice.show = false
self.clearFormDialoglnurldevice() self.clearFormDialoglnurldevice()

View File

@@ -803,9 +803,8 @@
self.productDialog.data = _.clone(link._data) self.productDialog.data = _.clone(link._data)
if (self.productDialog.data.categories) { 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:')) { if (self.productDialog.data.image.startsWith('data:')) {
self.productDialog.url = false self.productDialog.url = false

View File

@@ -809,7 +809,8 @@
this.createTheme(wallet, data) this.createTheme(wallet, data)
}, },
sendFormDataCharge: function () { 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 data = this.formDialogCharge.data
const wallet = this.g.user.wallets[0].inkey const wallet = this.g.user.wallets[0].inkey
data.amount = parseInt(data.amount) data.amount = parseInt(data.amount)

View File

@@ -574,11 +574,12 @@
.inkey .inkey
) )
.then(function (response) { .then(function (response) {
self.emailaddresses = _.reject(self.emailaddresses, function ( self.emailaddresses = _.reject(
obj self.emailaddresses,
) { function (obj) {
return obj.id == emailaddressId return obj.id == emailaddressId
}) }
)
}) })
.catch(function (error) { .catch(function (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)

View File

@@ -484,9 +484,8 @@
var link = _.findWhere(this.domains, {id: formId}) var link = _.findWhere(this.domains, {id: formId})
console.log(link.id) console.log(link.id)
this.domainDialog.data = _.clone(link) 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 this.domainDialog.show = true
}, },
updateDomain: function (wallet, data) { updateDomain: function (wallet, data) {

View File

@@ -174,11 +174,12 @@ async function walletList(path) {
'/watchonly/api/v1/wallet/' + walletAccountId, '/watchonly/api/v1/wallet/' + walletAccountId,
this.adminkey this.adminkey
) )
this.walletAccounts = _.reject(this.walletAccounts, function ( this.walletAccounts = _.reject(
obj this.walletAccounts,
) { function (obj) {
return obj.id === walletAccountId return obj.id === walletAccountId
}) }
)
await this.refreshWalletAccounts() await this.refreshWalletAccounts()
} catch (error) { } catch (error) {
this.$q.notify({ this.$q.notify({

39
package-lock.json generated
View File

@@ -1,31 +1,54 @@
{ {
"name": "lnbits-legend", "name": "lnbits",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"devDependencies": { "devDependencies": {
"prettier": "2.1.1" "prettier": "2.8.3",
"pyright": "1.1.289"
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "2.1.1", "version": "2.8.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz",
"integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==", "integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==",
"dev": true, "dev": true,
"bin": { "bin": {
"prettier": "bin-prettier.js" "prettier": "bin-prettier.js"
}, },
"engines": { "engines": {
"node": ">=10.13.0" "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": { "dependencies": {
"prettier": { "prettier": {
"version": "2.1.1", "version": "2.8.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz",
"integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==", "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 "dev": true
} }
} }

View File

@@ -1,5 +1,6 @@
{ {
"devDependencies": { "devDependencies": {
"prettier": "2.1.1" "prettier": "2.8.3",
"pyright": "1.1.289"
} }
} }

View File

@@ -86,6 +86,14 @@ lnbits = "lnbits.server:main"
[tool.isort] [tool.isort]
profile = "black" profile = "black"
[tool.pyright]
include = [
"lnbits"
]
exclude = [
"lnbits/wallets/lnd_grpc_files",
]
[tool.mypy] [tool.mypy]
files = "lnbits" files = "lnbits"
exclude = """(?x)( exclude = """(?x)(