This commit is contained in:
parent
92246bc9d1
commit
8a4e4ce6d5
|
@ -22,98 +22,8 @@ google-analytics-data = "^0.18.3"
|
||||||
opensearch-py = "^2.4.2"
|
opensearch-py = "^2.4.2"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
setuptools = "^69.0.2"
|
ruff = "^0.2.1"
|
||||||
pyright = "^1.1.341"
|
|
||||||
pytest = "^7.4.2"
|
|
||||||
black = { version = "^23.12.0", python = ">=3.12" }
|
|
||||||
ruff = { version = "^0.1.15", python = ">=3.12" }
|
|
||||||
isort = "^5.13.2"
|
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core"]
|
requires = ["poetry-core"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
[[tool.poetry.packages]]
|
|
||||||
include = "./*"
|
|
||||||
|
|
||||||
[tool.setuptools.dynamic]
|
|
||||||
version = {attr = "core.__version__"}
|
|
||||||
readme = {file = "README.md"}
|
|
||||||
|
|
||||||
[tool.ruff]
|
|
||||||
line-length = 120
|
|
||||||
extend-select = [
|
|
||||||
# E and F are enabled by default
|
|
||||||
'B', # flake8-bugbear
|
|
||||||
'C4', # flake8-comprehensions
|
|
||||||
'C90', # mccabe
|
|
||||||
'I', # isort
|
|
||||||
'N', # pep8-naming
|
|
||||||
'Q', # flake8-quotes
|
|
||||||
'S', # flake8-bandit
|
|
||||||
'W', # pycodestyle
|
|
||||||
]
|
|
||||||
extend-ignore = [
|
|
||||||
'B008', # function calls in args defaults are fine
|
|
||||||
'B009', # getattr with constants is fine
|
|
||||||
'B034', # re.split won't confuse us
|
|
||||||
'B904', # rising without from is fine
|
|
||||||
'E501', # leave line length to black
|
|
||||||
'N818', # leave to us exceptions naming
|
|
||||||
'S101', # assert is fine
|
|
||||||
'E712', # allow == True
|
|
||||||
]
|
|
||||||
flake8-quotes = { inline-quotes = 'single', multiline-quotes = 'double' }
|
|
||||||
mccabe = { max-complexity = 13 }
|
|
||||||
target-version = "py312"
|
|
||||||
|
|
||||||
[tool.ruff.format]
|
|
||||||
quote-style = 'single'
|
|
||||||
|
|
||||||
[tool.black]
|
|
||||||
skip-string-normalization = true
|
|
||||||
|
|
||||||
[tool.ruff.isort]
|
|
||||||
combine-as-imports = true
|
|
||||||
lines-after-imports = 2
|
|
||||||
known-first-party = ['resolvers', 'services', 'orm', 'tests']
|
|
||||||
|
|
||||||
[tool.ruff.per-file-ignores]
|
|
||||||
'tests/**' = ['B018', 'S110', 'S501']
|
|
||||||
|
|
||||||
[tool.mypy]
|
|
||||||
python_version = "3.12"
|
|
||||||
warn_return_any = true
|
|
||||||
warn_unused_configs = true
|
|
||||||
ignore_missing_imports = true
|
|
||||||
exclude = ["nb"]
|
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
|
||||||
asyncio_mode = 'auto'
|
|
||||||
|
|
||||||
[tool.pyright]
|
|
||||||
venvPath = "."
|
|
||||||
venv = ".venv"
|
|
||||||
include = ["."]
|
|
||||||
useLibraryCodeForTypes = true
|
|
||||||
disableLanguageServices = false
|
|
||||||
disableOrganizeImports = false
|
|
||||||
reportMissingImports = false
|
|
||||||
reportMissingModuleSource = "warning"
|
|
||||||
reportImportCycles = "warning"
|
|
||||||
maxMemoryForLargeFile = 4096
|
|
||||||
pythonVersion = "3.12"
|
|
||||||
autoImportCompletions = true
|
|
||||||
useVirtualEnv = true
|
|
||||||
typeCheckingMode = "basic"
|
|
||||||
disableJediCompletion = false
|
|
||||||
disableCompletion = false
|
|
||||||
disableSnippetCompletion = false
|
|
||||||
disableGoToDefinition = false
|
|
||||||
disableRenaming = false
|
|
||||||
disableSignatureHelp = false
|
|
||||||
diagnostics = true
|
|
||||||
logLevel = "Information"
|
|
||||||
pluginSearchPaths = []
|
|
||||||
typings = {}
|
|
||||||
mergeTypeStubPackages = false
|
|
||||||
|
|
|
@ -170,12 +170,12 @@ async def load_author_with_stats(q):
|
||||||
)
|
)
|
||||||
likes_count = (
|
likes_count = (
|
||||||
session.query(AuthorRating)
|
session.query(AuthorRating)
|
||||||
.filter(and_(AuthorRating.author == author.id, AuthorRating.plus == True))
|
.filter(and_(AuthorRating.author == author.id, AuthorRating.plus.is_(True)))
|
||||||
.count()
|
.count()
|
||||||
)
|
)
|
||||||
dislikes_count = (
|
dislikes_count = (
|
||||||
session.query(AuthorRating)
|
session.query(AuthorRating)
|
||||||
.filter(and_(AuthorRating.author == author.id, AuthorRating.plus != True))
|
.filter(and_(AuthorRating.author == author.id, AuthorRating.plus.is_not(True)))
|
||||||
.count()
|
.count()
|
||||||
)
|
)
|
||||||
author.stat['rating'] = likes_count - dislikes_count
|
author.stat['rating'] = likes_count - dislikes_count
|
||||||
|
|
|
@ -95,7 +95,7 @@ def patch_main_topic(session, main_topic, shout):
|
||||||
.filter(
|
.filter(
|
||||||
and_(
|
and_(
|
||||||
ShoutTopic.shout == shout.id,
|
ShoutTopic.shout == shout.id,
|
||||||
ShoutTopic.main == True,
|
ShoutTopic.main.is_(True),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.first()
|
.first()
|
||||||
|
@ -163,8 +163,7 @@ def patch_topics(session, shout, topics_input):
|
||||||
async def update_shout(_, info, shout_id, shout_input=None, publish=False):
|
async def update_shout(_, info, shout_id, shout_input=None, publish=False):
|
||||||
user_id = info.context['user_id']
|
user_id = info.context['user_id']
|
||||||
roles = info.context['roles']
|
roles = info.context['roles']
|
||||||
if not shout_input:
|
shout_input = shout_input or {}
|
||||||
shout_input = {}
|
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
author = session.query(Author).filter(Author.user == user_id).first()
|
author = session.query(Author).filter(Author.user == user_id).first()
|
||||||
current_time = int(time.time())
|
current_time = int(time.time())
|
||||||
|
|
|
@ -94,7 +94,7 @@ async def get_shout(_, _info, slug=None, shout_id=None):
|
||||||
and_(
|
and_(
|
||||||
ShoutTopic.topic == Topic.id,
|
ShoutTopic.topic == Topic.id,
|
||||||
ShoutTopic.shout == shout.id,
|
ShoutTopic.shout == shout.id,
|
||||||
ShoutTopic.main == True,
|
ShoutTopic.main.is_(True),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.first()
|
.first()
|
||||||
|
@ -176,7 +176,7 @@ async def load_shouts_by(_, _info, options):
|
||||||
and_(
|
and_(
|
||||||
ShoutTopic.topic == Topic.id,
|
ShoutTopic.topic == Topic.id,
|
||||||
ShoutTopic.shout == shout.id,
|
ShoutTopic.shout == shout.id,
|
||||||
ShoutTopic.main == True,
|
ShoutTopic.main.is_(True),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.first()
|
.first()
|
||||||
|
@ -223,7 +223,7 @@ async def load_shouts_drafts(_, info):
|
||||||
and_(
|
and_(
|
||||||
ShoutTopic.topic == Topic.id,
|
ShoutTopic.topic == Topic.id,
|
||||||
ShoutTopic.shout == shout.id,
|
ShoutTopic.shout == shout.id,
|
||||||
ShoutTopic.main == True,
|
ShoutTopic.main.is_(True),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.first()
|
.first()
|
||||||
|
@ -297,7 +297,7 @@ async def load_shouts_feed(_, info, options):
|
||||||
and_(
|
and_(
|
||||||
ShoutTopic.topic == Topic.id,
|
ShoutTopic.topic == Topic.id,
|
||||||
ShoutTopic.shout == shout.id,
|
ShoutTopic.shout == shout.id,
|
||||||
ShoutTopic.main == True,
|
ShoutTopic.main.is_(True),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.first()
|
.first()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user