Skip to content

Commit

Permalink
fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
yurnov committed Mar 26, 2024
1 parent 31bb99b commit eb161b4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ jobs:
- name: Install pylint
run: |
python -m pip install pylint==3.0.3
python -m pip install pylint==3.1.0 black==24.3.0
# - name: Lint Python code with black
# run: |
# black --check --skip-string-normalization --line-length 120 bot

- name: Lint Python code
run: |
pylint --disable=R,C,W1203 bot/main.py
pylint --disable=R,C,W1203,W0105 bot/main.py
- name: Lint Dockerfile with hadolint
uses: hadolint/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ jobs:
- name: Install linters
run: |
python -m pip install pylint==3.0.3 black==24.3.0
python -m pip install pylint==3.1.0 black==24.3.0
# - name: Lint Python code with black
# run: |
# black --check --skip-string-normalization --line-length 120 bot

- name: Lint Python code with Pylint
run: |
find . -name *.py -exec pylint --disable=R,C,W1203 '{}' \;
pylint --disable=R,C,W1203,W0105 bot/main.py
- name: Lint Dockerfile with hadolint
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.black
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM python:3.12-slim

RUN python -m pip install requests~=2.31.0 python-dotenv~=1.0.1 black
RUN python -m pip install requests~=2.31.0 python-dotenv~=1.0.1 pytz==2024.1 black==24.3.0 pylint==3.1.0

CMD [ "black", "--skip-string-normalization", "--line-length", "120", "bot" ]
3 changes: 2 additions & 1 deletion black.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

docker build . -f Dockerfile.black -t black
docker run -it --rm -v $(pwd)/bot:/bot black
docker run -it --rm -v $(pwd)/bot:/bot black
docker run -it --rm -v $(pwd)/bot:/bot black pylint --disable=R,C,W1203,W0105 bot/main.py
6 changes: 3 additions & 3 deletions bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
from dotenv import load_dotenv
import time
from datetime import datetime, timedelta
from datetime import datetime
import pytz

"""
Expand Down Expand Up @@ -118,7 +118,7 @@

def get_data():
try:
response = requests.get(URL)
response = requests.get(URL, timeout=15)
response.raise_for_status()
except requests.exceptions.RequestException as e:
logger.error(f"Error while getting data: {e}")
Expand All @@ -129,7 +129,7 @@ def get_data():
def send_message(text):
url = f"https://api.telegram.org/bot{TOKEN}/sendMessage?chat_id={CHAT_ID}&text={text}"
try:
response = requests.get(url)
response = requests.get(url, timeout=20)
response.raise_for_status()
except requests.exceptions.RequestException as e:
logger.error(f"Error while sending message: {e}")
Expand Down

0 comments on commit eb161b4

Please sign in to comment.