From 3eb86fcf216d3491aa193ec316e50654aac45164 Mon Sep 17 00:00:00 2001 From: Samuel Therrien Date: Fri, 22 Mar 2024 14:54:56 -0400 Subject: [PATCH] Use relative imports --- .vscode/settings.json | 6 +++++- canopeum_backend/canopeum_backend/urls.py | 2 +- canopeum_backend/canopeum_backend/views.py | 4 ++-- canopeum_backend/pyproject.toml | 3 --- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0967a03eb..1dc28d978 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -39,6 +39,9 @@ "[json][jsonc]": { "editor.defaultFormatter": "vscode.json-language-features", }, + "[yaml]": { + "editor.defaultFormatter": "redhat.vscode-yaml" + }, "[python]": { "editor.defaultFormatter": "charliermarsh.ruff", "editor.tabSize": 4, @@ -61,6 +64,7 @@ "source.convertImportFormat" // Explicitly omiting "source.unusedImports", can be annoying when commenting code for debugging ], + "python.analysis.importFormat": "relative", "python.analysis.diagnosticMode": "workspace", "ruff.importStrategy": "fromEnvironment", // Use the Ruff extension instead @@ -110,5 +114,5 @@ "evenBetterToml.formatter.reorderArrays": true, "evenBetterToml.formatter.trailingNewline": true, // We like keeping TOML keys in a certain non-alphabetical order that feels more natural - "evenBetterToml.formatter.reorderKeys": false + "evenBetterToml.formatter.reorderKeys": false, } diff --git a/canopeum_backend/canopeum_backend/urls.py b/canopeum_backend/canopeum_backend/urls.py index cce43c868..af3e8fe5a 100644 --- a/canopeum_backend/canopeum_backend/urls.py +++ b/canopeum_backend/canopeum_backend/urls.py @@ -2,7 +2,7 @@ from django.urls import path from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView -from canopeum_backend.canopeum_backend import views +from . import views urlpatterns = [ path("admin/", admin.site.urls), diff --git a/canopeum_backend/canopeum_backend/views.py b/canopeum_backend/canopeum_backend/views.py index 9235c0382..842dd950c 100644 --- a/canopeum_backend/canopeum_backend/views.py +++ b/canopeum_backend/canopeum_backend/views.py @@ -9,8 +9,8 @@ from rest_framework.response import Response from rest_framework.views import APIView -from canopeum_backend.canopeum_backend.models import Announcement, Batch, Comment, Like, Post, Site -from canopeum_backend.canopeum_backend.serializers import ( +from .models import Announcement, Batch, Comment, Like, Post, Site +from .serializers import ( AnnouncementSerializer, AuthUserSerializer, BatchSerializer, diff --git a/canopeum_backend/pyproject.toml b/canopeum_backend/pyproject.toml index d3011249b..83722d4e0 100644 --- a/canopeum_backend/pyproject.toml +++ b/canopeum_backend/pyproject.toml @@ -83,9 +83,6 @@ allow-multiline = false [tool.ruff.lint.isort] combine-as-imports = true split-on-trailing-comma = false -# Unlike isort, Ruff only counts relative imports as local-folder by default for know. -# https://github.com/astral-sh/ruff/issues/3115 -# known-local-folder = [] # https://docs.astral.sh/ruff/settings/#mccabe [tool.ruff.lint.mccabe]