Skip to content

Commit 3a2a214

Browse files
authored
Merge branch 'master' into fix-cache-or-default-bugs
2 parents 4730884 + 5cda836 commit 3a2a214

32 files changed

+322
-180
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
18+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1919
os: [ubuntu-24.04]
2020
runs-on: ${{ matrix.os }}
2121
name: "${{ matrix.os }} Python: ${{ matrix.python-version }}"
2222
services:
2323
redis:
24-
image: redis:6.2.6
24+
image: redis:8.0-alpine
2525
ports:
2626
- 6379:6379
2727
memcached:
28-
image: memcached:1.6.12
28+
image: memcached:1.6-alpine
2929
ports:
3030
- 11211:11211
3131
mysql:
32-
image: mysql:8.0.27
32+
image: mysql:9.3.0
3333
env:
3434
MYSQL_ALLOW_EMPTY_PASSWORD: yes
3535
ports:
3636
- 3306:3306
3737
postgresql:
38-
image: postgis/postgis:14-master
38+
image: postgis/postgis:17-3.5-alpine
3939
env:
4040
POSTGRES_HOST_AUTH_METHOD: trust
4141
ports:
@@ -45,17 +45,17 @@ jobs:
4545
run: |
4646
sudo apt-get update
4747
sudo apt-get install binutils libproj-dev gdal-bin libmemcached-dev libsqlite3-mod-spatialite
48-
- uses: actions/checkout@v3
48+
- uses: actions/checkout@v4
4949
with:
5050
fetch-depth: 0
5151
- name: Set up Python ${{ matrix.python-version }}
52-
uses: actions/setup-python@v4
52+
uses: actions/setup-python@v5
5353
with:
5454
python-version: ${{ matrix.python-version }}
5555
- name: Install dependencies
5656
run: |
5757
pip install -U "pip>=23.1.1"
58-
pip install -U "tox-gh-actions==3.1.0" coverage
58+
pip install -U "tox-gh-actions==3.3.0" coverage
5959
- name: Log versions
6060
run: |
6161
python --version

.github/workflows/pre-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
permissions:
1111
id-token: write
1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414
with:
1515
fetch-depth: 0
1616
- name: Set up Python 3.9
17-
uses: actions/setup-python@v4
17+
uses: actions/setup-python@v5
1818
with:
1919
python-version: 3.9
2020
- name: Install dependencies
@@ -26,7 +26,7 @@ jobs:
2626
- name: Build
2727
run: python -m build
2828
- name: Publish to PyPI
29-
uses: pypa/gh-action-pypi-publish@v1.8.5
29+
uses: pypa/gh-action-pypi-publish@v1.12.4
3030
with:
3131
skip-existing: true
3232
verbose: true

.github/workflows/release.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ jobs:
3838
permissions:
3939
id-token: write
4040
steps:
41-
- uses: actions/checkout@v3
41+
- uses: actions/checkout@v4
4242
with:
4343
ref: ${{ needs.determine-tag.outputs.release-tag }}
4444
fetch-depth: 0
4545
- name: Set up Python 3.9
46-
uses: actions/setup-python@v4
46+
uses: actions/setup-python@v5
4747
with:
4848
python-version: 3.9
4949
- name: Install dependencies
@@ -53,9 +53,8 @@ jobs:
5353
- name: Build
5454
run: python -m build
5555
- name: Publish to PyPI
56-
uses: pypa/gh-action-pypi-publish@v1.8.5
56+
uses: pypa/gh-action-pypi-publish@v1.12.4
5757
with:
5858
skip-existing: true
5959
verbose: true
6060
print-hash: true
61-

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks:
6+
- id: check-case-conflict
7+
- id: check-merge-conflict
8+
- id: check-yaml
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
12+
- repo: https://github.com/adamchainz/django-upgrade
13+
rev: "1.25.0"
14+
hooks:
15+
- id: django-upgrade
16+
args: [--target-version, "4.2"]
17+
18+
- repo: https://github.com/astral-sh/ruff-pre-commit
19+
rev: v0.11.13
20+
hooks:
21+
- id: ruff-check
22+
name: ruff check
23+
args: ["--fix"]
24+
- id: ruff-format
25+
name: ruff format

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## v2.4.0 - UNPUBLISHED
44

55
* Add support for Django 5.0 and Python 3.12.
6+
* Replace black, flake8 and isort with Ruff
7+
* Drop support for Django 3.2 (Python 3.7), 4.0 and 4.1
68

79
## v2.3.1 - May 2nd, 2023
810

CODE_OF_CONDUCT.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
2+
# Django Commons Code of Conduct
3+
4+
## Our Pledge
5+
6+
We as members, contributors, and leaders pledge to make participation in our
7+
community a harassment-free experience for everyone, regardless of age, body
8+
size, visible or invisible disability, ethnicity, sex characteristics, gender
9+
identity and expression, level of experience, education, socio-economic status,
10+
nationality, personal appearance, race, caste, color, religion, or sexual
11+
identity and orientation.
12+
13+
We pledge to act and interact in ways that contribute to an open, welcoming,
14+
diverse, inclusive, and healthy community.
15+
16+
## Our Standards
17+
18+
Examples of behavior that contributes to a positive environment for our
19+
community include:
20+
21+
* Demonstrating empathy and kindness toward other people
22+
* Being respectful of differing opinions, viewpoints, and experiences
23+
* Giving and gracefully accepting constructive feedback
24+
* Accepting responsibility and apologizing to those affected by our mistakes,
25+
and learning from the experience
26+
* Focusing on what is best not just for us as individuals, but for the overall
27+
community
28+
29+
Examples of unacceptable behavior include:
30+
31+
* The use of sexualized language or imagery, and sexual attention or advances of
32+
any kind
33+
* Trolling, insulting or derogatory comments, and personal or political attacks
34+
* Public or private harassment
35+
* Publishing others' private information, such as a physical or email address,
36+
without their explicit permission
37+
* Other conduct which could reasonably be considered inappropriate in a
38+
professional setting
39+
40+
## Enforcement Responsibilities
41+
42+
Community leaders are responsible for clarifying and enforcing our standards of
43+
acceptable behavior and will take appropriate and fair corrective action in
44+
response to any behavior that they deem inappropriate, threatening, offensive,
45+
or harmful.
46+
47+
Community leaders have the right and responsibility to remove, edit, or reject
48+
comments, commits, code, wiki edits, issues, and other contributions that are
49+
not aligned to this Code of Conduct, and will communicate reasons for moderation
50+
decisions when appropriate.
51+
52+
## Scope
53+
54+
This Code of Conduct applies within all community spaces, and also applies when
55+
an individual is officially representing the community in public spaces.
56+
Examples of representing our community include using an official email address,
57+
posting via an official social media account, or acting as an appointed
58+
representative at an online or offline event.
59+
60+
## Enforcement
61+
62+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
63+
reported to the community leaders responsible for enforcement at
64+
65+
All complaints will be reviewed and investigated promptly and fairly.
66+
67+
All community leaders are obligated to respect the privacy and security of the
68+
reporter of any incident.
69+
70+
## Enforcement Guidelines
71+
72+
Community leaders will follow these Community Impact Guidelines in determining
73+
the consequences for any action they deem in violation of this Code of Conduct:
74+
75+
### 1. Warning
76+
77+
**Community Impact**: Use of inappropriate language or other behavior deemed
78+
unprofessional or unwelcome in the community.
79+
80+
**Consequence**: A warning with consequences for continued behavior. No
81+
interaction with the people involved, including unsolicited interaction with
82+
those enforcing the Code of Conduct, for a specified period of time. This
83+
includes avoiding interactions in community spaces as well as external channels
84+
like social media. Violating these terms may lead to a temporary or permanent
85+
ban.
86+
87+
### 2. Temporary Ban
88+
89+
**Community Impact**: A serious violation of community standards, including
90+
sustained inappropriate behavior.
91+
92+
**Consequence**: A temporary ban from any sort of interaction or public
93+
communication with the community for a specified period of time. No public or
94+
private interaction with the people involved, including unsolicited interaction
95+
with those enforcing the Code of Conduct, is allowed during this period.
96+
Violating these terms may lead to a permanent ban.
97+
98+
### 3. Permanent Ban
99+
100+
**Community Impact**: Demonstrating a pattern of violation of community
101+
standards, including sustained inappropriate behavior, harassment of an
102+
individual, or aggression toward or disparagement of classes of individuals.
103+
104+
**Consequence**: A permanent ban from any sort of public interaction within the
105+
community.
106+
107+
## Attribution
108+
109+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
110+
version 2.1, available at
111+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
112+
113+
Community Impact Guidelines were inspired by
114+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
115+
116+
For answers to common questions about this code of conduct, see the FAQ at
117+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
118+
[https://www.contributor-covenant.org/translations][translations].
119+
120+
[homepage]: https://www.contributor-covenant.org
121+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
122+
[Mozilla CoC]: https://github.com/mozilla/diversity
123+
[FAQ]: https://www.contributor-covenant.org/faq
124+
[translations]: https://www.contributor-covenant.org/translations

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,3 @@
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201201
limitations under the License.
202-

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Export Django monitoring metrics for Prometheus.io
88
[![Build Status](https://github.com/korfuri/django-prometheus/actions/workflows/ci.yml/badge.svg)](https://github.com/korfuri/django-prometheus/actions/workflows/ci.yml)
99
[![Coverage Status](https://coveralls.io/repos/github/korfuri/django-prometheus/badge.svg?branch=master)](https://coveralls.io/github/korfuri/django-prometheus?branch=master)
1010
[![PyPi page link -- Python versions](https://img.shields.io/pypi/pyversions/django-prometheus.svg)](https://pypi.python.org/pypi/django-prometheus)
11-
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
11+
1212

1313
## Features
1414

@@ -22,8 +22,8 @@ This library provides Prometheus metrics for Django related operations:
2222

2323
### Requirements
2424

25-
* Django >= 3.2
26-
* Python 3.7 and above.
25+
* Django >= 4.2
26+
* Python 3.9 and above.
2727

2828
### Installation
2929

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django import VERSION as DJANGO_VERSION
1+
from django.core.cache.backends.redis import RedisCache as DjangoRedisCache
22
from django_redis import cache, exceptions
33

44
from django_prometheus.cache.metrics import (
@@ -21,7 +21,7 @@ def get(self, key, default=None, version=None, client=None):
2121
django_cache_get_fail_total.labels(backend="redis").inc()
2222
if self._ignore_exceptions:
2323
if self._log_ignored_exceptions:
24-
cache.logger.error(str(e))
24+
self.logger.error(str(e))
2525
return default
2626
raise
2727
else:
@@ -33,20 +33,17 @@ def get(self, key, default=None, version=None, client=None):
3333
return default
3434

3535

36-
if DJANGO_VERSION >= (4, 0):
37-
from django.core.cache.backends.redis import RedisCache as DjangoRedisCache
38-
39-
class NativeRedisCache(DjangoRedisCache):
40-
def get(self, key, default=None, version=None):
41-
django_cache_get_total.labels(backend="native_redis").inc()
42-
try:
43-
result = super().get(key, default=None, version=version)
44-
except Exception:
45-
django_cache_get_fail_total.labels(backend="native_redis").inc()
46-
raise
47-
if result is not None:
48-
django_cache_hits_total.labels(backend="native_redis").inc()
49-
return result
50-
else:
51-
django_cache_misses_total.labels(backend="native_redis").inc()
52-
return default
36+
class NativeRedisCache(DjangoRedisCache):
37+
def get(self, key, default=None, version=None):
38+
django_cache_get_total.labels(backend="native_redis").inc()
39+
try:
40+
result = super().get(key, default=None, version=version)
41+
except Exception:
42+
django_cache_get_fail_total.labels(backend="native_redis").inc()
43+
raise
44+
if result is not None:
45+
django_cache_hits_total.labels(backend="native_redis").inc()
46+
return result
47+
else:
48+
django_cache_misses_total.labels(backend="native_redis").inc()
49+
return default

django_prometheus/db/backends/common.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)