Skip to content

Commit

Permalink
Merge pull request #437 from chirizxc/develop
Browse files Browse the repository at this point in the history
fix: enable ignored ruff rules and sort rules by name
  • Loading branch information
Tishka17 authored Nov 6, 2024
2 parents 447da89 + c8cfd0a commit d951f7e
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 43 deletions.
48 changes: 21 additions & 27 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,42 @@ exclude = ["docs"]

lint.select = ["ALL"]
lint.ignore = [
"ARG",
"ANN",
"ARG",
"D",
"DTZ",
"TD",
"A002",
"ASYNC230",
"BLE001",
"EM101",
"EM102",
"PT001",
"PT023",
"SIM108",
"SIM114",
"TRY003",
"TCH003",
"PLW2901",
"RET505",
"PLR0913",
"UP038",
"TCH001",
"SIM103",
"ISC003",
"A002",
"FA100",
"TRY400",
"FBT001",
"FBT002",
"S311",
"N818",
"B904",
"FIX002",
"RUF012",
"ISC002",
"ISC003",
"N818",
"PLR0913",
"PLW2901",
"PYI034",
"RET505",
"S311",
"SIM103",
"SIM108",
"SIM114",
"TCH001",
"TCH002",
"TCH003",
"TRY003",
"TRY201",
"ISC002",
"ASYNC230",
"TRY400",
"UP007",
"N804",
"B008",
"BLE001",
"RUF009",
"PYI034",
"UP038",
]


[lint.per-file-ignores]
"src/aiogram_dialog/tools/**" = [
"S101",
Expand Down
2 changes: 1 addition & 1 deletion src/aiogram_dialog/context/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _state(self, state: str) -> State:
if real_state.state == state:
return real_state
except KeyError:
raise UnknownState(f"Unknown state group {group}")
raise UnknownState(f"Unknown state group {group}") from None
raise UnknownState(f"Unknown state {state}")

def _parse_access_settings(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ async def start(event: Any, dialog_manager: DialogManager):
await dialog_manager.start(MainSG.start, mode=StartMode.RESET_STACK)


@pytest.fixture()
@pytest.fixture
def message_manager():
return MockMessageManager()


@pytest.fixture()
@pytest.fixture
def dp(message_manager):
dp = Dispatcher(storage=JsonMemoryStorage())
dp.include_router(Dialog(window))
setup_dialogs(dp, message_manager=message_manager)
return dp


@pytest.fixture()
@pytest.fixture
def client(dp):
return BotClient(dp)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@ async def add_shared(event: Any, dialog_manager: DialogManager):
))


@pytest.fixture()
@pytest.fixture
def message_manager():
return MockMessageManager()


@pytest.fixture()
@pytest.fixture
def dp(message_manager):
dp = Dispatcher(storage=JsonMemoryStorage())
dp.include_router(Dialog(window))
setup_dialogs(dp, message_manager=message_manager)
return dp


@pytest.fixture()
@pytest.fixture
def client(dp):
return BotClient(dp, chat_id=-1, user_id=1, chat_type="group")


@pytest.fixture()
@pytest.fixture
def second_client(dp):
return BotClient(dp, chat_id=-1, user_id=2, chat_type="group")

Expand Down
6 changes: 3 additions & 3 deletions tests/test_nested_transitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ async def on_process_result_sub(_, __, dialog_manager: DialogManager):
await dialog_manager.done()


@pytest.fixture()
@pytest.fixture
def message_manager() -> MockMessageManager:
return MockMessageManager()


@pytest.fixture()
@pytest.fixture
def client(dp) -> BotClient:
return BotClient(dp)


@pytest.fixture()
@pytest.fixture
def dp(message_manager: MockMessageManager):
dp = Dispatcher(storage=JsonMemoryStorage())
dp.message.register(start, CommandStart())
Expand Down
6 changes: 3 additions & 3 deletions tests/test_transitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ async def start(message: Message, dialog_manager: DialogManager):
await dialog_manager.start(MainSG.start, mode=StartMode.RESET_STACK)


@pytest.fixture()
@pytest.fixture
def message_manager() -> MockMessageManager:
return MockMessageManager()


@pytest.fixture()
@pytest.fixture
def client(dp) -> BotClient:
return BotClient(dp)


@pytest.fixture()
@pytest.fixture
def dp(message_manager: MockMessageManager):
dp = Dispatcher(storage=JsonMemoryStorage())
dp.message.register(start, CommandStart())
Expand Down
2 changes: 1 addition & 1 deletion tests/widgets/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from aiogram_dialog.api.entities import Context


@pytest.fixture()
@pytest.fixture
def mock_manager() -> DialogManager:
manager = MagicMock()
context = Context(
Expand Down
2 changes: 1 addition & 1 deletion tests/widgets/text/test_jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from aiogram_dialog.widgets.text import Jinja


@pytest.fixture()
@pytest.fixture
def mock_manager(mock_manager) -> DialogManager:
mock_manager.middleware_data = {}
return mock_manager
Expand Down

0 comments on commit d951f7e

Please sign in to comment.