Skip to content

Commit

Permalink
Upgrade Django support (5.0) (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugorodgerbrown authored Nov 14, 2023
1 parent 8b43b8b commit 0317b49
Show file tree
Hide file tree
Showing 20 changed files with 135 additions and 167 deletions.
38 changes: 0 additions & 38 deletions .flake8

This file was deleted.

139 changes: 87 additions & 52 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,93 @@
name: Python / Django

on:
push:
branches:
- master
push:
branches:
- master

pull_request:
types: [opened, synchronize, reopened]
pull_request:
types: [opened, synchronize, reopened]

jobs:
format:
name: Check formatting
runs-on: ubuntu-latest
strategy:
matrix:
toxenv: [fmt, lint, mypy]
env:
TOXENV: ${{ matrix.toxenv }}

steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install and run tox
run: |
pip install tox
tox
test:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.9", "3.10", "3.11"]
django: [32,41,main]

env:
TOXENV: py${{ matrix.python }}-django${{ matrix.django }}

steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install and run tox
run: |
pip install tox
tox
format:
name: Check formatting
runs-on: ubuntu-latest
strategy:
matrix:
toxenv: [fmt, lint, mypy]
env:
TOXENV: ${{ matrix.toxenv }}

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python (3.11)
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install and run tox
run: |
pip install tox
tox
checks:
name: Run Django checks
runs-on: ubuntu-latest
strategy:
matrix:
toxenv: ["django-checks"]
env:
TOXENV: ${{ matrix.toxenv }}

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python (3.11)
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install and run tox
run: |
pip install tox
tox
test:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.9", "3.10", "3.11", "3.12"]
# build LTS version, next version, HEAD
django: ["32", "42", "50", "main"]
exclude:
- python: "3.9"
django: "50"
- python: "3.9"
django: "main"
- python: "3.10"
django: "main"
- python: "3.11"
django: "32"
- python: "3.12"
django: "32"

env:
TOXENV: django${{ matrix.django }}-py${{ matrix.python }}

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install and run tox
run: |
pip install tox
tox
8 changes: 0 additions & 8 deletions .isort.cfg

This file was deleted.

32 changes: 7 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,26 @@
repos:
# python import sorting - will amend files
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort

# python code formatting - will amend files
- repo: https://github.com/ambv/black
rev: 22.10.0
rev: 23.10.1
hooks:
- id: black

- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0
hooks:
- id: pyupgrade

# Flake8 includes pyflakes, pycodestyle, mccabe, pydocstyle, bandit
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: "v0.1.5"
hooks:
- id: flake8
additional_dependencies:
- flake8-bandit
- flake8-blind-except
- flake8-docstrings
- flake8-logging-format
- flake8-print
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

# python static type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.990
rev: v1.7.0
hooks:
- id: mypy
# additional_dependencies:
args:
- --disallow-untyped-defs
- --disallow-incomplete-defs
- --check-untyped-defs
- --no-implicit-optional
- --ignore-missing-imports
- --follow-imports=silent
exclude: ^tests
8 changes: 7 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## v1.1

- Added support for Django 5.0
- Added support for Python 3.12
- Replaced flake8, isort with ruff

No code changes.

## v1.0

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT Licence (MIT)

Copyright (c) 2022 YunoJuno Ltd
Copyright (c) 2023 YunoJuno Limited

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 5 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-request-profiler"
version = "1.0"
version = "1.1"
description = "A simple Django project profiler for timing HTTP requests."
authors = ["YunoJuno <[email protected]>"]
license = "MIT"
Expand All @@ -16,35 +16,30 @@ classifiers = [
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 5.0",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
packages = [
{ include = "request_profiler" }
]

[tool.poetry.dependencies]
python = "^3.9"
django = "^3.2 || ^4.0"
django = "^3.2 || ^4.0 || ^5.0"

[tool.poetry.dev-dependencies]
black = "*"
coverage = "*"
flake8 = "*"
flake8-bandit = "*"
flake8-blind-except = "*"
flake8-docstrings = "*"
flake8-logging-format = "*"
flake8-print = "*"
freezegun = "*"
isort = "*"
mypy = "*"
pre-commit = "*"
pytest = "*"
pytest-cov = "*"
pytest-django = "*"
ruff = "*"
tox = "*"

[build-system]
Expand Down
2 changes: 0 additions & 2 deletions request_profiler/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@


class RuleSetAdmin(admin.ModelAdmin):

list_display = ("enabled", "uri_regex", "user_filter_type", "user_group_filter")


class ProfilingRecordAdmin(admin.ModelAdmin):

list_display = (
"start_ts",
"user",
Expand Down
1 change: 0 additions & 1 deletion request_profiler/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class RequestProfilerAppConfig(AppConfig):

name = "request_profiler"
verbose_name = "Request Profiler"
default_auto_field = "django.db.models.BigAutoField"
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class Command(BaseCommand):

help = "Truncate the profiler log after a specified number days."

def add_arguments(self, parser: CommandParser) -> None:
Expand Down
1 change: 0 additions & 1 deletion request_profiler/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [("request_profiler", "0001_initial")]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [("request_profiler", "0002_profilingrecord_http_referer")]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [("request_profiler", "0003_profilingrecord_query_string")]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("request_profiler", "0004_profilingrecord_query_count"),
]
Expand Down
1 change: 0 additions & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class CustomUserManager(BaseUserManager):

# override this method
def _create_user(
self,
Expand Down
Loading

0 comments on commit 0317b49

Please sign in to comment.