Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lnbits/core/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,9 +921,9 @@ async def api_uninstall_extension(
)
async def get_extension_releases(ext_id: str):
try:
extension_releases: List[
ExtensionRelease
] = await InstallableExtension.get_extension_releases(ext_id)
extension_releases: List[ExtensionRelease] = (
await InstallableExtension.get_extension_releases(ext_id)
)

installed_ext = await get_installed_extension(ext_id)
if not installed_ext:
Expand Down
8 changes: 5 additions & 3 deletions lnbits/core/views/node_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ async def api_delete_channel(
) -> Optional[List[NodeChannel]]:
return await node.close_channel(
short_id,
ChannelPoint(funding_txid=funding_txid, output_index=output_index)
if funding_txid is not None and output_index is not None
else None,
(
ChannelPoint(funding_txid=funding_txid, output_index=output_index)
if funding_txid is not None and output_index is not None
else None
),
force,
)

Expand Down
6 changes: 3 additions & 3 deletions lnbits/extension_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,9 @@ async def get_extension_releases(cls, ext_id: str) -> List["ExtensionRelease"]:
async def get_extension_release(
cls, ext_id: str, source_repo: str, archive: str, version: str
) -> Optional["ExtensionRelease"]:
all_releases: List[
ExtensionRelease
] = await InstallableExtension.get_extension_releases(ext_id)
all_releases: List[ExtensionRelease] = (
await InstallableExtension.get_extension_releases(ext_id)
)
selected_release = [
r
for r in all_releases
Expand Down
24 changes: 14 additions & 10 deletions lnbits/nodes/cln.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,21 @@ async def get_channels(self) -> List[NodeChannel]:
state=(
ChannelState.ACTIVE
if ch["state"] == "CHANNELD_NORMAL"
else ChannelState.PENDING
if ch["state"] in ("CHANNELD_AWAITING_LOCKIN", "OPENINGD")
else ChannelState.CLOSED
if ch["state"]
in (
"CHANNELD_CLOSING",
"CLOSINGD_COMPLETE",
"CLOSINGD_SIGEXCHANGE",
"ONCHAIN",
else (
ChannelState.PENDING
if ch["state"] in ("CHANNELD_AWAITING_LOCKIN", "OPENINGD")
else (
ChannelState.CLOSED
if ch["state"]
in (
"CHANNELD_CLOSING",
"CLOSINGD_COMPLETE",
"CLOSINGD_SIGEXCHANGE",
"ONCHAIN",
)
else ChannelState.INACTIVE
)
)
else ChannelState.INACTIVE
),
)
for ch in funds["channels"]
Expand Down
20 changes: 12 additions & 8 deletions lnbits/nodes/lndrest.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,11 @@ async def parse_pending(raw_channels, state):
remote_msat=msat(channel["remote_balance"]),
total_msat=msat(channel["capacity"]),
),
state=ChannelState.ACTIVE
if channel["active"]
else ChannelState.INACTIVE,
state=(
ChannelState.ACTIVE
if channel["active"]
else ChannelState.INACTIVE
),
# name=channel['peer_alias'],
name=info.alias,
color=info.color,
Expand Down Expand Up @@ -318,11 +320,13 @@ async def get_payments(
amount=payment["value_msat"],
fee=payment["fee_msat"],
time=payment["creation_date"],
destination=await self.get_peer_info(
payment["htlcs"][0]["route"]["hops"][-1]["pub_key"]
)
if payment["htlcs"]
else None,
destination=(
await self.get_peer_info(
payment["htlcs"][0]["route"]["hops"][-1]["pub_key"]
)
if payment["htlcs"]
else None
),
bolt11=payment["payment_request"],
preimage=payment["payment_preimage"],
)
Expand Down
84 changes: 44 additions & 40 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 16 additions & 38 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ wallycore = {version = "^1.0.0", optional = true}
liquid = ["wallycore"]

[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
black = "^24.2.0"
pytest-asyncio = "^0.21.0"
pytest = "^7.3.2"
pytest-cov = "^4.1.0"
mypy = "^1.5.1"
types-protobuf = "^4.24.0.2"
pre-commit = "^3.2.2"
openapi-spec-validator = "^0.6.0"
ruff = "^0.0.291"
ruff = "^0.3.0"
# not our dependency but needed indirectly by openapi-spec-validator
# we want to use 0.10.3 because newer versions are broken on nix
rpds-py = "0.10.3"
Expand Down Expand Up @@ -152,53 +152,31 @@ extend-exclude = """(
# Same as Black. + 10% rule of black
line-length = 88

# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
# (`I`) is for `isort`.
select = ["E", "F", "I"]
# Exclude generated files.
extend-exclude = [
"lnbits/wallets/lnd_grpc_files"
]

[tool.ruff.lint]
# Enable:
# F - pyflakes
# E - pycodestyle errors
# W - pycodestyle warnings
# I - isort
select = ["F", "E", "W", "I"]
ignore = []

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Exclude a variety of commonly ignored directories.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come these directories do not have to be excluded anymore?

Copy link
Collaborator Author

@prusnak prusnak Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because i changed exclude to extend-exclude which keeps the default excluded dirs and only extends them (also the default automatically excludes what is in the .gitignore)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

exclude = [
"lnbits/static",
"lnbits/extensions",
"lnbits/wallets/lnd_grpc_files",
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python
# target-version = "py39"

# Ignore unused imports in __init__.py files.
[tool.ruff.extend-per-file-ignores]
[tool.ruff.lint.extend-per-file-ignores]
"__init__.py" = ["F401", "F403"]

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10