Skip to content

Commit

Permalink
Update Python warnings configuration in .env.sample
Browse files Browse the repository at this point in the history
  • Loading branch information
eduzen committed Jun 1, 2024
1 parent 3cb6c07 commit c04b72e
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LOG_LEVEL=DEBUG
openweathermap_token=token
PORT=5000
POSTGRES_PASSWORD=password
PYTHONWARNINGS=ignore:Unverified HTTPS request
PYTHONWARNINGS="ignore:Unverified HTTPS request"
TMDB_API_KEY=somekey
TOKEN=token
TWITTER_ACCESS_TOKEN_SECRET=secret
Expand Down
11 changes: 0 additions & 11 deletions .flake8

This file was deleted.

8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ repos:
args: [--py311-plus]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.2'
rev: 'v0.4.7'
hooks:
# Run the linter
- id: ruff
args: ["--fix"]
# Run the formatter
- id: ruff-format

- repo: https://github.com/pycqa/isort
rev: 5.13.2 # Use the ref you want to point at
hooks:
- id: isort
args: ["--profile", "black"]
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN apt-get update && \
apt-get autoclean -y && \
rm -rf /var/lib/apt/lists/*

RUN pip install -U wheel pip
RUN pip install -U wheel pip pip-tools

COPY pyproject.toml requirements.txt ./

Expand Down
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
version: '3.9'

volumes:
pgdata:
shell_history:

services:

eduzenbot:
tty: true
image: eduzen/bot:latest
Expand Down
4 changes: 2 additions & 2 deletions eduzenbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import logging
import os
from pathlib import Path

import sentry_sdk
from dotenv import load_dotenv
from rich.logging import RichHandler
from telegram.ext import CallbackQueryHandler, CommandHandler, Filters

Expand All @@ -13,8 +15,6 @@
from eduzenbot.plugins.messages.unknown import unknown
from eduzenbot.scripts.initialize_db import create_db_tables
from eduzenbot.telegram_bot import TelegramBot
from dotenv import load_dotenv
from pathlib import Path

# Load environment variables from .env file
env_path = Path("../.env")
Expand Down
2 changes: 1 addition & 1 deletion eduzenbot/auth/restricted.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
from functools import wraps
from collections.abc import Callable
from functools import wraps

from telegram import Update
from telegram.ext import CallbackContext
Expand Down
2 changes: 1 addition & 1 deletion eduzenbot/decorators.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import functools
import logging
from collections.abc import Callable
from functools import wraps
from typing import Any
from collections.abc import Callable

import peewee
from telegram import Update
Expand Down
7 changes: 3 additions & 4 deletions eduzenbot/plugins/commands/hackernews/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from types import SimpleNamespace
from typing import Any

import pendulum
import requests
from cachetools import TTLCache, cached
from telegram import ChatAction, Update
Expand Down Expand Up @@ -73,14 +72,14 @@ def get_hackernews_help(story_type: STORIES = STORIES.TOP) -> str:
def parse_hackernews(story_id: int) -> str:
raw_story = get_item(story_id)
story = SimpleNamespace(**raw_story)
now = pendulum.now()
date = now - pendulum.from_timestamp(story.time)
# now = pendulum.now()
# date = now - pendulum.from_timestamp(story.time)
try:
url = story.url
except AttributeError:
url = ""
story_text = (
f"[{story.title}]({url})\n Score: {story.score} Hace: {date.in_words()}"
f"[{story.title}]({url})\n" # Score: {story.score} Hace: {date.in_words()}"
)
return story_text

Expand Down
3 changes: 1 addition & 2 deletions eduzenbot/telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import logging
import os
import pkgutil
from collections.abc import Sequence
from collections.abc import Callable, Sequence
from functools import partial
from typing import Any
from collections.abc import Callable

import attr
import pytz
Expand Down
21 changes: 19 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set dotenv-load := true

dco := "docker-compose"
run := "{{dco}} run --rm eduzenbot"
dco := "docker compose"
run := "docker compose run --rm eduzenbot"

os:
#!/usr/bin/env bash
Expand All @@ -18,6 +18,17 @@ dockershell:
#!/usr/bin/env bash
{{run}} eduzenbot bash

update-requirements-dev:
{{run}} pip-compile --upgrade --extra=dev pyproject.toml -o requirements-dev.txt

update-requirements-prod:
{{run}} pip-compile --upgrade pyproject.toml -o requirements.txt

update-requirements:
just update-requirements-dev
just update-requirements-prod


test:
#!/usr/bin/env bash
{{run}} pytest --cov=eduzenbot --cov-report=term-missing
Expand Down Expand Up @@ -51,6 +62,12 @@ compile:
compile-dev:
pip-compile --extra=dev pyproject.toml -o requirements-dev.txt

format:
pre-commit run --all-files

fmt:
just format

clean:
#!/usr/bin/env python3
import pathlib, shutil
Expand Down

0 comments on commit c04b72e

Please sign in to comment.