Enable more ruff checks in deltachat-rpc-client

This commit is contained in:
link2xt
2023-02-21 11:17:10 +00:00
parent f07206bd6c
commit 05a274a5f3
11 changed files with 53 additions and 20 deletions

View File

@@ -25,7 +25,35 @@ deltachat_rpc_client = [
line-length = 120 line-length = 120
[tool.ruff] [tool.ruff]
select = ["E", "F", "W", "N", "YTT", "B", "C4", "ISC", "ICN", "PT", "RET", "SIM", "TID", "ARG", "DTZ", "ERA", "PLC", "PLE", "PLW", "PIE", "COM"] select = [
"E", "W", # pycodestyle
"F", # Pyflakes
"N", # pep8-naming
"I", # isort
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"COM", # flake8-commas
"DTZ", # flake8-datetimez
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"RET", # flake8-return
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
"YTT", # flake8-2020
"ERA", # eradicate
"PLC", # Pylint Convention
"PLE", # Pylint Error
"PLW", # Pylint Warning
"RUF006" # asyncio-dangling-task
]
line-length = 120 line-length = 120
[tool.isort] [tool.isort]

View File

@@ -1,15 +1,15 @@
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
from dataclasses import dataclass from dataclasses import dataclass
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
from ._utils import AttrDict from ._utils import AttrDict
from .chat import Chat from .chat import Chat
from .const import ChatlistFlag, ContactFlag, SpecialContactId from .const import ChatlistFlag, ContactFlag, SpecialContactId
from .contact import Contact from .contact import Contact
from .message import Message from .message import Message
from .rpc import Rpc
if TYPE_CHECKING: if TYPE_CHECKING:
from .deltachat import DeltaChat from .deltachat import DeltaChat
from .rpc import Rpc
@dataclass @dataclass

View File

@@ -1,16 +1,17 @@
import calendar import calendar
from datetime import datetime
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
from dataclasses import dataclass from dataclasses import dataclass
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
from ._utils import AttrDict from ._utils import AttrDict
from .const import ChatVisibility from .const import ChatVisibility
from .contact import Contact from .contact import Contact
from .message import Message from .message import Message
from .rpc import Rpc
if TYPE_CHECKING: if TYPE_CHECKING:
from datetime import datetime
from .account import Account from .account import Account
from .rpc import Rpc
@dataclass @dataclass

View File

@@ -2,6 +2,7 @@
import inspect import inspect
import logging import logging
from typing import ( from typing import (
TYPE_CHECKING,
Callable, Callable,
Coroutine, Coroutine,
Dict, Dict,
@@ -13,8 +14,6 @@ from typing import (
Union, Union,
) )
from deltachat_rpc_client.account import Account
from ._utils import ( from ._utils import (
AttrDict, AttrDict,
parse_system_add_remove, parse_system_add_remove,
@@ -31,6 +30,9 @@ from .events import (
RawEvent, RawEvent,
) )
if TYPE_CHECKING:
from deltachat_rpc_client.account import Account
class Client: class Client:
"""Simple Delta Chat client that listen to events of a single account.""" """Simple Delta Chat client that listen to events of a single account."""

View File

@@ -1,12 +1,12 @@
from typing import TYPE_CHECKING
from dataclasses import dataclass from dataclasses import dataclass
from typing import TYPE_CHECKING
from ._utils import AttrDict from ._utils import AttrDict
from .rpc import Rpc
if TYPE_CHECKING: if TYPE_CHECKING:
from .account import Account from .account import Account
from .chat import Chat from .chat import Chat
from .rpc import Rpc
@dataclass @dataclass

View File

@@ -1,8 +1,10 @@
from typing import Dict, List from typing import TYPE_CHECKING, Dict, List
from ._utils import AttrDict from ._utils import AttrDict
from .account import Account from .account import Account
from .rpc import Rpc
if TYPE_CHECKING:
from .rpc import Rpc
class DeltaChat: class DeltaChat:

View File

@@ -2,11 +2,13 @@
import inspect import inspect
import re import re
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Callable, Iterable, Iterator, Optional, Set, Tuple, Union from typing import TYPE_CHECKING, Callable, Iterable, Iterator, Optional, Set, Tuple, Union
from ._utils import AttrDict
from .const import EventType from .const import EventType
if TYPE_CHECKING:
from ._utils import AttrDict
def _tuple_of(obj, type_: type) -> tuple: def _tuple_of(obj, type_: type) -> tuple:
if not obj: if not obj:

View File

@@ -1,13 +1,13 @@
import json import json
from typing import TYPE_CHECKING, Union
from dataclasses import dataclass from dataclasses import dataclass
from typing import TYPE_CHECKING, Union
from ._utils import AttrDict from ._utils import AttrDict
from .contact import Contact from .contact import Contact
from .rpc import Rpc
if TYPE_CHECKING: if TYPE_CHECKING:
from .account import Account from .account import Account
from .rpc import Rpc
@dataclass @dataclass

View File

@@ -1,8 +1,8 @@
import asyncio
import json import json
import os import os
from typing import AsyncGenerator, List, Optional from typing import AsyncGenerator, List, Optional
import asyncio
import aiohttp import aiohttp
import pytest_asyncio import pytest_asyncio

View File

@@ -1,8 +1,7 @@
import asyncio
from unittest.mock import MagicMock from unittest.mock import MagicMock
import pytest import pytest
import asyncio
from deltachat_rpc_client import EventType, events from deltachat_rpc_client import EventType, events
from deltachat_rpc_client.rpc import JsonRpcError from deltachat_rpc_client.rpc import JsonRpcError

View File

@@ -1,5 +1,4 @@
import pytest import pytest
from deltachat_rpc_client import EventType from deltachat_rpc_client import EventType