Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump dependencies #168

Merged
merged 4 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump python-telegram-bot to version 21.0.1
- Bump python-telegram-bot to version 21.6
- Bump cryptography to version 43.0.1
- Bump PyYAML to version 6.0.2
- Bump pytz to version 2024.2

## [3.1.0] - 2024-02-18

Expand Down
14 changes: 9 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ classifiers = [
]
dependencies = [
"APScheduler==3.10.4",
"cryptography==42.0.4",
"python-telegram-bot==21.0.1",
"pytz==2023.3.post1",
"PyYAML==6.0.1",
"cryptography==43.0.1",
"python-telegram-bot==21.6",
"pytz==2024.2",
"PyYAML==6.0.2",
]
dynamic = ['version']

Expand Down Expand Up @@ -100,7 +100,11 @@ ignore = ['tests', '_version.py']
fail-under = '10.0'

[tool.pylint.'MESSAGES CONTROL']
disable = ["missing-module-docstring", "too-few-public-methods"]
disable = [
"missing-module-docstring",
"too-few-public-methods",
"too-many-positional-arguments",
]

[tool.pylint.format]
max-line-length = 120
Expand Down
1 change: 1 addition & 0 deletions src/spotted/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def init_db():
"""Initialize the database.
If the debug.reset_on_load setting is True, it will delete the database and create a new one.
"""
DbManager.register_adapters_and_converters()
if Config.settings_get("debug", "reset_on_load"):
DbManager.query_from_file("config", "db", "post_db_del.sql")
DbManager.query_from_file("config", "db", "post_db_init.sql")
10 changes: 10 additions & 0 deletions src/spotted/data/db_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Handles the management of databases"""

import datetime
import logging
import os
import sqlite3
Expand All @@ -13,6 +14,15 @@
class DbManager:
"""Class that handles the management of databases"""

@staticmethod
def register_adapters_and_converters():
"""
Registers the adapter and converters for the datetime type.
Needed from python 3.12 onwards, as the default option has been deprecated
"""
sqlite3.register_adapter(datetime.datetime, lambda val: val.isoformat())
sqlite3.register_converter("timestamp", lambda val: datetime.datetime.fromisoformat(val.decode()))

@staticmethod
def row_factory(cursor: sqlite3.Cursor, row: dict) -> dict:
"""Converts the rows from the database into a dictionary
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def create_test_db() -> DbManager:
"""Called once per at the beginning of this class.
Creates and initializes the local database
"""
DbManager.register_adapters_and_converters()
yield DbManager
os.remove(Config.debug_get("db_file"))

Expand Down
5 changes: 4 additions & 1 deletion tests/integration/telegram_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from telegram import (
Chat,
ChatFullInfo,
InlineKeyboardMarkup,
LinkPreviewOptions,
Message,
Expand Down Expand Up @@ -95,11 +96,13 @@ def post(self, endpoint: str, data: dict) -> dict | bool | None:
if endpoint == "getChat":
return self.__chats.get(
data["chat_id"],
Chat(
ChatFullInfo(
id=data["chat_id"],
username=f"@{data['chat_id']}",
first_name=str(data["chat_id"]),
type=Chat.PRIVATE,
accent_color_id=1,
max_reaction_count=1,
),
).to_dict()
if endpoint == "forwardMessage":
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def get_chat() -> Chat:
"username": "u_name",
"first_name": "f_name",
"last_name": "l_name",
"bio": "bio",
}
return Chat(**chat_data)

Expand Down
Loading