Skip to content

Commit

Permalink
pylint now fails under a rating of 7, current rating 9.42. Refactored…
Browse files Browse the repository at this point in the history
… some stuff
TheFJcurve committed Nov 11, 2024
1 parent 411a562 commit bedb405
Showing 7 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -17,8 +17,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
cd backend
pip install -r requirements.txt
pip install pylint
- name: Analysing the code with pylint
run: |
cd backend
pylint $(git ls-files '*.py')
pylint --fail-under=7.0 $(git ls-files '*.py')
3 changes: 3 additions & 0 deletions backend/code/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
TODO
"""
7 changes: 4 additions & 3 deletions backend/code/main.py
Original file line number Diff line number Diff line change
@@ -6,13 +6,14 @@
import io
import json

from code.utils import get_filename_by_file_id, custom_hash
from code.p2p_client import P2PClient
from code.file_tokenizer import SenderTokenizer

from pathlib import Path
from flask_cors import CORS
from flask import Flask, request, jsonify, send_file

from utils import get_filename_by_file_id, custom_hash
from p2p_client import P2PClient
from file_tokenizer import SenderTokenizer

app = Flask(__name__)
CORS(app)
6 changes: 3 additions & 3 deletions backend/code/p2p_client.py
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@

from pathlib import Path

from utils import get_filename_by_file_id
from file_tokenizer import ReceiverTokenizer
from code.utils import get_filename_by_file_id
from code.file_tokenizer import ReceiverTokenizer
from config import DISCOVERY_PORT, CHAT_PORT, MAX_UDP_PACKET, DISCOVERY_ADDRESS


@@ -23,7 +23,7 @@ class P2PClient:

def __init__(self):
self.user_id = uuid.uuid1().__str__()
self.peers = dict()
self.peers = {}
self.discovery_socket = socket.socket(
socket.AF_INET, socket.SOCK_DGRAM)
self.discovery_socket.setsockopt(
2 changes: 1 addition & 1 deletion backend/code/utils.py
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ def find_file(directory, filename):

if os.path.exists(directory):
for file in os.listdir(directory):
name, ext = os.path.splitext(file)
name, _ = os.path.splitext(file)
if name == filename:
return file
return None
4 changes: 4 additions & 0 deletions backend/test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
TODO
"""

import os
import sys

4 changes: 2 additions & 2 deletions backend/test/test_utils.py
Original file line number Diff line number Diff line change
@@ -11,14 +11,14 @@ class TestUtils(unittest.TestCase):
TODO
"""

def test_find_file_with_garbage_file_name_returns_None(self):
def test_find_file_with_garbage_file_name_returns_none(self):
"""
If a file does not exist, find_file should return None
"""

self.assertEqual(find_file("uploads", "random_file.txt"), None)

def test_find_file_with_garbage_directory_name_returns_None(self):
def test_find_file_with_garbage_directory_name_returns_none(self):
"""
If a directory does not exist, find_file should return None
"""

0 comments on commit bedb405

Please sign in to comment.