Skip to content

Commit 8f199c5

Browse files
authored
Merge pull request #8 from coder8080/ruff
Use ruff for linting
2 parents 5c2d552 + eed4f31 commit 8f199c5

File tree

19 files changed

+54
-42
lines changed

19 files changed

+54
-42
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ cython_debug/
173173
# PyPI configuration file
174174
.pypirc
175175

176+
.vscode
177+
176178
pg_data
177179
redis_data
178180
certs/*

Dockerfile.lint

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ FROM pypy:3
22

33
WORKDIR /usr/src/app
44

5-
RUN pip install flake8 --no-cache-dir
5+
RUN pip install ruff
66
COPY requirements.txt .
7-
RUN pip install -r requirements.txt --no-cache-dir
7+
RUN pip install -r requirements.txt --no-cache-dir
88
COPY . .
99

10-
CMD ["python", "-m", "flake8", "./src"]
10+
CMD ["ruff", "check", "--extend-select", "I"]

src/entities/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from .constants import TOKEN, POSTGRES_USER, POSTGRES_PASSWORD, ADMINS, TEXT
2-
from .fsm import States, storage
3-
from .utils import get_update_user_info, log_error, get_keyboard
1+
from .constants import ADMINS, POSTGRES_PASSWORD, POSTGRES_USER, TEXT, TOKEN
42
from .create_bot import bot
53
from .dispatcher import dp
4+
from .fsm import States, storage
65
from .logs import logger
6+
from .utils import get_keyboard, get_update_user_info, log_error
77

88
__all__ = ["TOKEN", "POSTGRES_USER", "POSTGRES_PASSWORD", "ADMINS", "TEXT",
99
"States", "get_update_user_info", "storage", "bot", "dp",

src/entities/dispatcher.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
from typing import Any, Awaitable, Callable, Dict
2+
13
from aiogram import Dispatcher
24
from aiogram.types import Update
3-
from typing import Callable, Dict, Any, Awaitable
45

5-
from models import User
6-
from routers import index_router, link_router, utility_router, \
7-
create_cert_router, check_cert_router, check_count_router
86
from entities import get_update_user_info, storage
7+
from models import User
8+
from routers import (
9+
check_cert_router,
10+
check_count_router,
11+
create_cert_router,
12+
index_router,
13+
link_router,
14+
utility_router,
15+
)
916

1017
dp = Dispatcher(storage=storage)
1118

@@ -20,7 +27,7 @@ async def get_user(handler: Callable[[Update, Dict[str, Any]],
2027
return await handler(update, data)
2128

2229
if not username:
23-
username = "unknown:" + chat_id
30+
username = "unknown:" + str(chat_id)
2431

2532
query = User.select().where(User.chat_id == chat_id)
2633
if not await query.aio_exists():

src/entities/fsm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from aiogram.fsm.state import StatesGroup, State
2-
from aiogram.fsm.storage.redis import RedisStorage
31
import redis.asyncio as redis
2+
from aiogram.fsm.state import State, StatesGroup
3+
from aiogram.fsm.storage.redis import RedisStorage
44

55

66
class States(StatesGroup):

src/entities/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
from aiogram.utils.keyboard import ReplyKeyboardBuilder
33

44
from entities import ADMINS, TEXT
5+
from models import User
6+
57
from .create_bot import bot
68
from .logs import logger
7-
from models import User
89

910

1011
def admin_markup() -> ReplyKeyboardMarkup:

src/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22

3-
from entities import bot
4-
from entities import dp
3+
from entities import bot, dp
54

65

76
async def main():

src/models/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .user import User, init_user
2-
from .link import Link, init_link
31
from .cert import Cert, init_cert
2+
from .link import Link, init_link
3+
from .user import User, init_user
44

55
init_user()
66
init_link()

src/models/cert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from random import randint
22

3-
from peewee import TextField, BooleanField
3+
from peewee import BooleanField, TextField
44

5-
from .db import db, BaseModel
5+
from .db import BaseModel, db
66

77

88
def cert_code():

src/models/db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import peewee_async
2-
from entities import POSTGRES_USER, POSTGRES_PASSWORD
2+
3+
from entities import POSTGRES_PASSWORD, POSTGRES_USER
34

45
db = peewee_async.PsycopgDatabase('usmile',
56
user=POSTGRES_USER,

0 commit comments

Comments
 (0)