Lint service code

This commit is contained in:
Damir Modyarov 2023-08-08 13:27:12 +03:00
parent e1959f7232
commit 7bc8d2da91
3 changed files with 7 additions and 6 deletions

View File

@ -1,10 +1,11 @@
from sqlalchemy import Boolean, Column, Integer, String, DateTime
from sqlalchemy import Boolean, Column, DateTime, Integer, String
from redirect.db import Base
class Link(Base):
"""Model of a short link that defines slug and target of a redirect."""
__tablename__ = "short_link"
id = Column(Integer, primary_key=True, index=True)

View File

@ -10,10 +10,10 @@ class AppSettings(BaseSettings):
database_url: str = "postgresql://postgres:postgres@127.0.0.1:5432/akarpov"
class Config:
env_prefix = ''
env_file = '.env'
env_file_encoding = 'utf-8'
extra = 'allow'
env_prefix = ""
env_file = ".env"
env_file_encoding = "utf-8"
extra = "allow"
settings = AppSettings()

View File

@ -10,7 +10,7 @@ def slug_to_link_id(slug: str) -> int:
"""Converts given slug to an id of a link."""
link_id = 0
try:
for i, ch in enumerate(slug[:SLUG_CUTOFF - 1:-1]):
for i, ch in enumerate(slug[:SLUG_CUTOFF - 1:-1]): # fmt: skip
value = URL_CHARACTERS.index(ch)
link_id += value * len(URL_CHARACTERS) ** i
except ValueError: