Add mypy Github action
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
name: Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '*.py'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
mypy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: 3.9
|
||||||
|
architecture: x64
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Install mypy
|
||||||
|
run: pip install mypy
|
||||||
|
- name: Run mypy
|
||||||
|
uses: sasanquaneuf/mypy-github-action@releases/v1
|
||||||
|
with:
|
||||||
|
checkName: 'mypy' # NOTE: this needs to be the same as the job name
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
+7
-6
@@ -2,8 +2,10 @@ import pymongo
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from bson import ObjectId
|
||||||
|
|
||||||
class MongoWorker():
|
|
||||||
|
class MongoWorker:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.client = pymongo.MongoClient(host="127.0.0.1", port=27017)
|
self.client = pymongo.MongoClient(host="127.0.0.1", port=27017)
|
||||||
self.db = self.client["data"]
|
self.db = self.client["data"]
|
||||||
@@ -14,13 +16,13 @@ class MongoWorker():
|
|||||||
print(self.client.list_database_names())
|
print(self.client.list_database_names())
|
||||||
print(self.db.list_collection_names())
|
print(self.db.list_collection_names())
|
||||||
|
|
||||||
def find_user(self, user_id:int) -> None:
|
def find_user(self, user_id: int) -> dict:
|
||||||
result = self.users_data.find_one({"user_id": user_id})
|
result = self.users_data.find_one({"user_id": user_id})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def add_user(self, user_id:int, username:str, first_name:str, last_name:str, photo_path:str) -> bool:
|
def add_user(self, user_id: int, username: str, first_name: str, last_name: str, photo_path: str) -> ObjectId:
|
||||||
try:
|
try:
|
||||||
self.users_data.insert_one({"user_id": user_id,
|
res = self.users_data.insert_one({"user_id": user_id,
|
||||||
"username": username,
|
"username": username,
|
||||||
"first_name": first_name,
|
"first_name": first_name,
|
||||||
"last_name": last_name,
|
"last_name": last_name,
|
||||||
@@ -31,10 +33,9 @@ class MongoWorker():
|
|||||||
"comments_ids": [],
|
"comments_ids": [],
|
||||||
"registration_date": datetime.now().isoformat()
|
"registration_date": datetime.now().isoformat()
|
||||||
})
|
})
|
||||||
return True
|
return res.inserted_id
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
print(exception)
|
print(exception)
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user