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

Revert "[~] Added flake8. R: There was no check for unsupported imports. FB: …" #145

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ repos:
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
args: [--config=flake8, src/backend/]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
Expand Down
7 changes: 0 additions & 7 deletions flake8

This file was deleted.

51 changes: 1 addition & 50 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ django-celery-beat = "^2.6.0"
pre-commit = "^3.5.0"
black = "^23.12.1"
isort = "5.13.2"
flake8 = "^7.0.0"

[build-system]
requires = ["poetry-core"]
Expand Down
5 changes: 1 addition & 4 deletions src/backend/api/v1/general/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ class CounterApiView(generics.RetrieveAPIView):
def get(self, request):
with connection.cursor() as cursor:
cursor.execute(
"""
SELECT count(*) from projects_project union all SELECT count(*)
from users_user
"""
"SELECT count(*) from projects_project union all SELECT count(*) from users_user "
)
row = cursor.fetchall()
return Response({"projects": row[0][0], "users": row[1][0]})
Expand Down
4 changes: 2 additions & 2 deletions src/backend/api/v1/profile/serializers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from rest_framework import serializers
from rest_framework import generics, serializers

from apps.profile.models import Profile, UserSkill, UserSpecialization
from apps.projects.models import Skill, Specialist


class ProfileSerializer(serializers.Serializer):
"""Сериализатор на просмотр профиля с учетом выбора видимости контактов."""
"""Модель сериализатора на просмотр профиля с учетом выбора видимости контактов"""

class Meta:
model = Profile
Expand Down
2 changes: 1 addition & 1 deletion src/backend/api/v1/profile/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.urls import path
from django.urls import include, path

from api.v1.profile.views import ProfileListAPIView, ProfileView

Expand Down
2 changes: 2 additions & 0 deletions src/backend/api/v1/profile/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.db.models import Q
from rest_framework import generics

from api.v1.profile.permissions import IsOwnerOrReadOnly
Expand All @@ -6,6 +7,7 @@
ProfileUpdateSerializer,
)
from apps.profile.models import Profile
from apps.projects.models import Project


class ProfileView(generics.UpdateAPIView):
Expand Down
2 changes: 2 additions & 0 deletions src/backend/api/v1/users/serializers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.contrib.auth import get_user_model
from djoser.serializers import (
SendEmailResetSerializer,
UserCreatePasswordRetypeSerializer,
UserSerializer,
)
from rest_framework import serializers

from api.v1.users import constants

Expand Down
17 changes: 6 additions & 11 deletions src/backend/apps/profile/validators.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from datetime import date

from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from PIL import Image


class BirthdayValidator:
"""
Валидатор, не позволяющий пользователю добавить будущую дату в качестве
своего дня рождения.
"""
"""Валидатор, не позволяющий пользователю добавить будущую дату в качестве своего дня рождения"""

def __init__(self, min_age=0):
self.min_age = min_age
Expand All @@ -21,27 +19,24 @@ def __call__(self, value):


def validate_image_format(value):
"""
Валидатор, позволяющий добавить аватар только определенного формата .png,
.jpg или .jpeg.
"""
"""Валидатор, позволяющий добавить аватар только определенного формата .png, .jpg или .jpeg"""
valid_extensions = [".png", ".jpg", ".jpeg"]
ext = value.name.lower().split(".")[-1]
if ext not in valid_extensions:
if not ext in valid_extensions:
raise ValidationError(
"Пожалуйста загрузите файл с расширением PNG или JPEG."
)


def validate_image_size(value):
"""Валидатор, не позволяющий загрузить картинку размером больше 10 MB."""
"""Валидатор, не позволяющий загрузить картинку размером больше 10 MB"""
max_size = 10 * 1024 * 1024 # 10 MB
if value.size > max_size:
raise ValidationError("Файл не должен превышать размер 10 MB.")


def validate_image_resolution(value):
"""Валидатор, ограничивающий размер картинки."""
"""Валидатор, ограничивающий размер картинки"""
min_width, min_height = 320, 240
max_width, max_height = 1920, 1080

Expand Down
5 changes: 1 addition & 4 deletions src/backend/apps/projects/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
"символов."
)
REGEX_DIRECTION_NAME = r"(^[A-Za-zА-Яа-яЁё]+)\Z"
REGEX_DIRECTION_NAME_ERROR_TEXT = (
"Направление разработки может содержать: кириллические и латинские "
"символы."
)
REGEX_DIRECTION_NAME_ERROR_TEXT = "Направление разработки может содержать: кириллические и латинские символы."

MAX_LENGTH_LINK = 256
MIN_LENGTH_LINK = 5
Expand Down
1 change: 1 addition & 0 deletions src/backend/apps/users/validators.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from typing import Any

from django.core.exceptions import ValidationError
Expand Down
2 changes: 1 addition & 1 deletion src/backend/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
LOCAL_APPS: list = [
"apps.general",
"apps.users",
"apps.project",
"apps.projects",
"apps.profile",
]

Expand Down
2 changes: 2 additions & 0 deletions src/backend/config/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List

from django.contrib import admin
from django.urls import include, path

Expand Down