Skip to content

Commit 53f3205

Browse files
authored
Merge pull request #312 from rtibblesbot/issue-311-e91a09
Replace flake8/isort with ruff, add uv supply-chain safety
2 parents 0571813 + bbb618b commit 53f3205

103 files changed

Lines changed: 1255 additions & 1664 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ updates:
99
interval: "weekly"
1010
day: "friday"
1111
time: "00:00"
12+
cooldown:
13+
days: 7
1214
# Maintain dependencies for Github Actions
1315
- package-ecosystem: "github-actions"
1416
directory: "/"
@@ -20,3 +22,5 @@ updates:
2022
github:
2123
patterns:
2224
- "actions/*"
25+
cooldown:
26+
days: 7

.pre-commit-config.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@ repos:
33
rev: v2.2.3
44
hooks:
55
- id: trailing-whitespace
6-
- id: flake8
76
- id: check-yaml
87
- id: check-added-large-files
98
exclude: 'uv.lock'
10-
- id: debug-statements
119
- id: end-of-file-fixer
1210
exclude: '^.+?\.json$'
13-
- repo: https://github.com/PyCQA/flake8
14-
rev: 7.1.2
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.15.8
1513
hooks:
16-
- id: flake8
17-
additional_dependencies: ['flake8-print==5.0.0']
18-
- repo: https://github.com/asottile/reorder_python_imports
19-
rev: v1.4.0
14+
- id: ruff
15+
args: [--fix]
16+
- id: ruff-format
17+
- repo: https://github.com/astral-sh/uv-pre-commit
18+
rev: 0.11.3
2019
hooks:
21-
- id: reorder-python-imports
22-
language_version: python3
20+
- id: uv-lock
2321
- repo: https://github.com/google/yamlfmt
2422
rev: v0.14.0
2523
hooks:

codecov.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
codecov:
22
notify:
33
require_ci_to_pass: yes
4-
54
coverage:
65
precision: 2
76
round: down
87
range: "70...100"
9-
108
status:
119
project: yes
1210
patch: yes
1311
changes: no
14-
1512
parsers:
1613
gcov:
1714
branch_detection:
1815
conditional: yes
1916
loop: yes
2017
method: no
2118
macro: no
22-
2319
comment:
2420
layout: "header, diff"
2521
behavior: default

docs/deletion/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ There are times, such as GDPR removal requests, when it's necessary to actually
1919
This is handled using a ``HardDeletedModels`` table. Subclasses of ``SyncableModel`` should override the ``delete`` method to take a ``hard_delete`` boolean, and add the record to the ``HardDeletedModels`` table when this is passed.
2020

2121
On serialization, Morango clears the ``serialized`` field entry in the store for records in ``HardDeletedModels`` and turns on the ``hard_deleted`` flag. Upon syncing with other Morango instances, the hard deletion will propagate to the store record of other instances.
22-

docs/merging/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ In the illustration above:
3636
5. When *Device A* syncs data with *Device B* again (the arrow), there is a conflict because both devices have modified ``r``.
3737

3838
It is up to the implementing application to determine what the merge conflict resolution strategy is.
39-

morango/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
try:
22
from importlib.metadata import version
3+
34
__version__ = version("morango")
45
except ImportError:
56
# Fallback for older Python versions or when package is not installed

morango/api/permissions.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import json
22

3-
from django.contrib.auth import authenticate
4-
from django.contrib.auth import get_user_model
5-
from rest_framework import authentication
6-
from rest_framework import exceptions
7-
from rest_framework import permissions
3+
from django.contrib.auth import authenticate, get_user_model
4+
from rest_framework import authentication, exceptions, permissions
85

96
from morango.models.core import TransferSession
107
from morango.utils import SETTINGS
@@ -61,11 +58,7 @@ def has_permission(self, request, view):
6158
if hasattr(request.user, "has_morango_certificate_scope_permission"):
6259
scope_definition_id = request.data.get("scope_definition")
6360
scope_params = json.loads(request.data.get("scope_params"))
64-
if (
65-
scope_definition_id
66-
and scope_params
67-
and isinstance(scope_params, dict)
68-
):
61+
if scope_definition_id and scope_params and isinstance(scope_params, dict):
6962
return request.user.has_morango_certificate_scope_permission(
7063
scope_definition_id, scope_params
7164
)
@@ -89,9 +82,7 @@ def has_permission(self, request, view):
8982
sesh_id = request.query_params.get("transfer_session_id")
9083
if not sesh_id:
9184
return False
92-
if not TransferSession.objects.filter(
93-
id=sesh_id, active=True, push=False
94-
).exists():
85+
if not TransferSession.objects.filter(id=sesh_id, active=True, push=False).exists():
9586
return False
9687
return True
9788

morango/api/serializers.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
from rest_framework import exceptions
2-
from rest_framework import serializers
1+
from rest_framework import exceptions, serializers
32
from rest_framework.fields import ReadOnlyField
43

54
from ..models.certificates import Nonce
6-
from ..models.core import Buffer
7-
from ..models.core import Certificate
8-
from ..models.core import InstanceIDModel
9-
from ..models.core import RecordMaxCounterBuffer
10-
from ..models.core import SyncSession
11-
from ..models.core import TransferSession
5+
from ..models.core import (
6+
Buffer,
7+
Certificate,
8+
InstanceIDModel,
9+
RecordMaxCounterBuffer,
10+
SyncSession,
11+
TransferSession,
12+
)
1213
from ..models.fields.crypto import SharedKey
1314
from ..utils import SETTINGS
1415
from .fields import PublicKeyField
1516

1617

1718
class CertificateSerializer(serializers.ModelSerializer):
18-
1919
public_key = PublicKeyField()
2020

2121
def validate_parent(self, parent):
@@ -60,8 +60,8 @@ class Meta:
6060

6161

6262
class SyncSessionSerializer(serializers.ModelSerializer):
63-
client_instance = serializers.CharField(source='client_instance_json')
64-
server_instance = serializers.CharField(source='server_instance_json')
63+
client_instance = serializers.CharField(source="client_instance_json")
64+
server_instance = serializers.CharField(source="server_instance_json")
6565

6666
class Meta:
6767
model = SyncSession

morango/api/urls.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
from rest_framework import routers
22

3-
from .viewsets import BufferViewSet
4-
from .viewsets import CertificateChainViewSet
5-
from .viewsets import CertificateViewSet
6-
from .viewsets import MorangoInfoViewSet
7-
from .viewsets import NonceViewSet
8-
from .viewsets import PublicKeyViewSet
9-
from .viewsets import SyncSessionViewSet
10-
from .viewsets import TransferSessionViewSet
3+
from .viewsets import (
4+
BufferViewSet,
5+
CertificateChainViewSet,
6+
CertificateViewSet,
7+
MorangoInfoViewSet,
8+
NonceViewSet,
9+
PublicKeyViewSet,
10+
SyncSessionViewSet,
11+
TransferSessionViewSet,
12+
)
1113

1214
router = routers.SimpleRouter()
1315
router.register(r"certificates", CertificateViewSet, basename="certificates")
14-
router.register(
15-
r"certificatechain", CertificateChainViewSet, basename="certificatechain"
16-
)
16+
router.register(r"certificatechain", CertificateChainViewSet, basename="certificatechain")
1717
router.register(r"nonces", NonceViewSet, basename="nonces")
1818
router.register(r"syncsessions", SyncSessionViewSet, basename="syncsessions")
19-
router.register(
20-
r"transfersessions", TransferSessionViewSet, basename="transfersessions"
21-
)
19+
router.register(r"transfersessions", TransferSessionViewSet, basename="transfersessions")
2220
router.register(r"buffers", BufferViewSet, basename="buffers")
2321
router.register(r"morangoinfo", MorangoInfoViewSet, basename="morangoinfo")
2422
router.register(r"publickey", PublicKeyViewSet, basename="publickey")

0 commit comments

Comments
 (0)