Skip to content

Commit c571bb0

Browse files
authored
Refactored code base; modernized with pyproject.toml (#255)
1 parent d110821 commit c571bb0

Some content is hidden

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

54 files changed

+3677
-3054
lines changed

.coveragerc

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

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
## Description:
2-
**Related issue (if applicable):** refs #<!--apprise issue number goes here-->
2+
**Related issue (if applicable):** refs #<!--apprise-api issue number goes here-->
33

44
## Checklist
55
<!-- The following must be completed or your PR can't be merged -->
66
* [ ] The code change is tested and works locally.
77
* [ ] There is no commented out code in this PR.
8-
* [ ] No lint errors (use `flake8`)
8+
* [ ] No lint errors (use `ruff`)
99
* [ ] Tests added

.github/workflows/tests.yml

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,55 @@
1+
# Copyright (C) 2025 Chris Caron <[email protected]>
2+
# All rights reserved.
3+
#
4+
# This code is licensed under the MIT License.
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files(the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions :
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
# THE SOFTWARE.
123
name: Tests
224

325
on:
4-
5-
# On which repository actions to trigger the build.
626
push:
727
branches: [ master ]
828
pull_request:
929
branches: [ master ]
10-
11-
# Allow job to be triggered manually.
1230
workflow_dispatch:
1331

14-
# Cancel in-progress jobs when pushing to the same branch.
15-
concurrency:
16-
cancel-in-progress: true
17-
group: ${{ github.workflow }}-${{ github.ref }}
18-
1932
jobs:
20-
2133
tests:
34+
runs-on: ubuntu-latest
2235

23-
runs-on: ${{ matrix.os }}
24-
strategy:
25-
26-
# Run all jobs to completion (false), or cancel
27-
# all jobs once the first one fails (true).
28-
fail-fast: true
29-
30-
# Define a minimal test matrix, it will be
31-
# expanded using subsequent `include` items.
32-
matrix:
33-
os: ["ubuntu-latest"]
34-
python-version: ["3.12"]
35-
bare: [false]
36-
37-
defaults:
38-
run:
39-
shell: bash
40-
41-
env:
42-
OS: ${{ matrix.os }}
43-
PYTHON: ${{ matrix.python-version }}
44-
BARE: ${{ matrix.bare }}
45-
46-
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} ${{ matrix.bare && '(bare)' || '' }}
4736
steps:
48-
4937
- name: Acquire sources
5038
uses: actions/checkout@v4
5139

52-
- name: Install prerequisites (Linux)
53-
if: runner.os == 'Linux'
40+
- name: Install prerequisites
5441
run: |
5542
sudo apt-get update
5643
57-
- name: Install project dependencies (Baseline)
44+
- name: Install dependencies
5845
run: |
5946
pip install -r requirements.txt -r dev-requirements.txt
6047
61-
# For saving resources, code style checking is
62-
# only invoked within the `bare` environment.
63-
- name: Check code style
64-
if: matrix.bare == true
48+
- name: Lint with Ruff
6549
run: |
66-
flake8 apprise_api --count --show-source --statistics
50+
ruff check apprise_api
6751
68-
- name: Run tests
52+
- name: Run tests with coverage
6953
run: |
7054
coverage run -m pytest apprise_api
7155
@@ -74,9 +58,10 @@ jobs:
7458
coverage xml
7559
coverage report
7660
77-
- name: Upload coverage data
61+
- name: Upload coverage to Codecov
7862
uses: codecov/codecov-action@v5
7963
with:
8064
files: ./coverage.xml
8165
fail_ci_if_error: false
8266
token: ${{ secrets.CODECOV_TOKEN }}
67+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dist/
1616
downloads/
1717
eggs/
1818
.eggs/
19+
.local/
1920
lib64
2021
lib
2122
var/

Dockerfile.py312

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# BSD 2-Clause License
33
#
44
# Apprise-API - Push Notification Library.
5-
# Copyright (c) 2023, Chris Caron <[email protected]>
5+
# Copyright (c) 2025, Chris Caron <[email protected]>
66
#
77
# Redistribution and use in source and binary forms, with or without
88
# modification, are permitted provided that the following conditions are met:

README.md

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -616,33 +616,67 @@ spec:
616616
```
617617
618618
## Development Environment
619-
The following should get you a working development environment to test with:
619+
The following should get you a working development environment (min requirements are Python v3.12) to test with.
620+
621+
### Setup
620622
621623
```bash
622-
# Create a virtual environment in the same directory you
623-
# cloned this repository to:
624-
python -m venv .
624+
# Create and activate a Python 3.12 virtual environment:
625+
python3.12 -m venv .venv
626+
. .venv/bin/activate
627+
628+
# Install core dependencies:
625629

626-
# Activate it now:
627-
. ./bin/activate
630+
pip install -e '.[dev]'
631+
```
628632

629-
# install dependencies
630-
pip install -r dev-requirements.txt -r requirements.txt
633+
### Running the Dev Server
631634

632-
# Run a dev server (debug mode) accessible from your browser at:
633-
# -> http://localhost:8000/
635+
```bash
636+
# Start the development server in debug mode:
634637
./manage.py runserver
638+
# Then visit: http://localhost:8000/
639+
```
635640

641+
Or use Docker:
642+
```bash
643+
# It's this simple:
644+
docker compose up
636645
```
637646

638-
Some other useful development notes:
647+
### Quality Assurance and Testing (via Tox)
639648

640-
```bash
641-
# Check for any lint errors
642-
flake8 apprise_api
649+
The project uses `tox` to manage linting, testing, and formatting in a reproducible way.
643650

651+
```bash
644652
# Run unit tests
653+
tox -e test
654+
655+
# Test structure; calls ruff under the hood
656+
tox -e lint
657+
```
658+
659+
**Note**: You can combine environments, e.g.:
660+
```bash
661+
tox -e test,lint
662+
```
663+
664+
Automatically format your code if possible to pass linting after changes:
665+
```bash
666+
tox -e format
667+
```
668+
669+
### Manual Tools (optional)
670+
The following also works assuming you have provided all development dependencies (`pip install .[dev]`)
671+
```bash
672+
# Run unit tests manually (if needed)
645673
pytest apprise_api
674+
675+
# Lint code with Ruff
676+
ruff check .
677+
678+
# Format code with Ruff
679+
ruff format .
646680
```
647681

648682
## Apprise Integration
@@ -790,4 +824,6 @@ The colon `:` prefix is the switch that starts the re-mapping rule engine. You
790824

791825

792826
## Metrics Collection & Analysis
827+
793828
Basic Prometheus support added through `/metrics` reference point.
829+

apprise_api/api/apps.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Copyright (C) 2019 Chris Caron <[email protected]>
43
# All rights reserved.
@@ -26,4 +25,4 @@
2625

2726

2827
class ApiConfig(AppConfig):
29-
name = 'api'
28+
name = "api"

apprise_api/api/context_processors.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Copyright (C) 2020 Chris Caron <[email protected]>
43
# All rights reserved.
@@ -22,49 +21,50 @@
2221
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2322
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2423
# THE SOFTWARE.
25-
from .utils import gen_unique_config_id
26-
from .utils import ConfigCache
2724
from django.conf import settings
25+
2826
import apprise
2927

28+
from .utils import ConfigCache, gen_unique_config_id
29+
3030

3131
def stateful_mode(request):
3232
"""
3333
Returns our loaded Stateful Mode
3434
"""
35-
return {'STATEFUL_MODE': ConfigCache.mode}
35+
return {"STATEFUL_MODE": ConfigCache.mode}
3636

3737

3838
def config_lock(request):
3939
"""
4040
Returns the state of our global configuration lock
4141
"""
42-
return {'CONFIG_LOCK': settings.APPRISE_CONFIG_LOCK}
42+
return {"CONFIG_LOCK": settings.APPRISE_CONFIG_LOCK}
4343

4444

4545
def admin_enabled(request):
4646
"""
4747
Returns whether we allow the config list to be displayed
4848
"""
49-
return {'APPRISE_ADMIN': settings.APPRISE_ADMIN}
49+
return {"APPRISE_ADMIN": settings.APPRISE_ADMIN}
5050

5151

5252
def apprise_version(request):
5353
"""
5454
Returns the current version of apprise loaded under the hood
5555
"""
56-
return {'APPRISE_VERSION': apprise.__version__}
56+
return {"APPRISE_VERSION": apprise.__version__}
5757

5858

5959
def default_config_id(request):
6060
"""
6161
Returns a unique config identifier
6262
"""
63-
return {'DEFAULT_CONFIG_ID': request.default_config_id}
63+
return {"DEFAULT_CONFIG_ID": request.default_config_id}
6464

6565

6666
def unique_config_id(request):
6767
"""
6868
Returns a unique config identifier
6969
"""
70-
return {'UNIQUE_CONFIG_ID': gen_unique_config_id()}
70+
return {"UNIQUE_CONFIG_ID": gen_unique_config_id()}

0 commit comments

Comments
 (0)