Skip to content

Commit

Permalink
Fix: Ruff did not check code quality
Browse files Browse the repository at this point in the history
Solution: Add ruff to check the code quality and fix the reported errors.
  • Loading branch information
hoh committed Jun 13, 2024
1 parent f6d0b7b commit fd1b0e1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,19 @@ dependencies = [
"black==24.2.0",
"mypy==1.9.0",
"mypy-extensions==1.0.0",
# "ruff==0.1.15",
"ruff==0.4.8",
"isort==5.13.2",
]
[tool.hatch.envs.linting.scripts]
typing = "mypy --config-file=pyproject.toml {args:} ./src/ ./tests/ ./examples/"
style = [
# "ruff {args:.}",
"ruff {args:.} ./src/ ./tests/ ./examples/",
"black --check --diff {args:} ./src/ ./tests/ ./examples/",
"isort --check-only --profile black {args:} ./src/ ./tests/ ./examples/",
]
fmt = [
"black {args:} ./src/ ./tests/ ./examples/",
# "ruff --fix {args:.}",
"ruff --fix {args:.} ./src/ ./tests/ ./examples/",
"isort --profile black {args:} ./src/ ./tests/ ./examples/",
"style",
]
Expand All @@ -169,6 +169,7 @@ exclude = [
"conftest.py"
]
show_column_numbers = true
check_untyped_defs = true

# Import discovery
# Install types for third-party library stubs (e.g. from typeshed repository)
Expand Down Expand Up @@ -231,4 +232,4 @@ exclude_lines = [

# Don't complain about ineffective code:
"pass",
]
]
6 changes: 2 additions & 4 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import asyncio
import json
from functools import wraps
from io import BytesIO
from pathlib import Path
from tempfile import NamedTemporaryFile
Expand Down Expand Up @@ -196,10 +198,6 @@ def mock_session_with_post_success(
return client


import asyncio
from functools import wraps


def async_wrap(cls):
class AsyncWrapper:
def __init__(self, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def test_configured_domain():
url = "https://custom-domain-unit-test.aleph.sh"
hostname = hostname_from_url(url)
status = await alephdns.check_domain(hostname, TargetType.IPFS, "0xfakeaddress")
assert type(status) is dict
assert isinstance(status, dict)


@pytest.mark.asyncio
Expand All @@ -57,4 +57,4 @@ async def test_not_configured_domain():
hostname = hostname_from_url(url)
with pytest.raises(DomainConfigurationError):
status = await alephdns.check_domain(hostname, TargetType.IPFS, "0xfakeaddress")
assert type(status) is None
assert status is None
1 change: 0 additions & 1 deletion tests/unit/test_download.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import tempfile
from pathlib import Path
from unittest.mock import AsyncMock, patch

import pytest

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_wallet_ethereum.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def test_ledger_eth_account():

address = account.get_address()
assert address
assert type(address) is str
assert isinstance(address, str)
assert len(address) == 42

message = Message("ETH", account.get_address(), "SomeType", "ItemHash")
Expand Down

0 comments on commit fd1b0e1

Please sign in to comment.