Обсуждение Django
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Go down
WhoKnows
WhoKnows
Posts : 13
Join date : 2024-02-06

[1] Кратко про настройку mypy Empty [1] Кратко про настройку mypy

Fri Feb 09, 2024 8:49 pm
pyproject.toml
Code:
[tool.mypy]
mypy_path = "./lyceum"
plugins = ["mypy_django_plugin.main"]
strict = true

[tool.django-stubs]
django_settings_module = "lyceum.settings"
prod.txt
Code:
Django==4.2
python-dotenv==1.0.1
django-stubs==1.12.0
django-stubs-ext==4.2.7
test.txt
Code:
Django==4.2
flake8=7.0.0
pep8-naming==0.13.3
flake8-quotes==3.3.2
flake8-import-order==0.18.2
black==24.1.1
django-stubs==1.12.0
django-stubs-ext==4.2.7
python-dotenv==1.0.1
примерно как должен выглядеть settings.py - лучше поправьте
Code:
import os
from pathlib import Path
from typing import List

import django_stubs_ext


django_stubs_ext.monkeypatch()
BASE_DIR = Path(__file__).resolve().parent.parent


SECRET_KEY = os.environ.get("SECRET_KEY", "FAKE_TEST")

DEBUG = os.environ.get("DEBUG", "True").lower() == "true"

ALLOWED_HOSTS: List[str] = os.environ.get("ALLOWED_HOSTS", "*").split()
Ну и mypy
Code:
mypy:
  stage: static_type_checking
  script:
   - pip install mypy
   - pip install python-dotenv
   - pip install django-stubs==1.12.0
   - pip install django-stubs-ext==4.2.7
   - mypy --verbose .
Back to top
Permissions in this forum:
You cannot reply to topics in this forum