Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add conf.py for library configuration #97

Merged
merged 3 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added

- Added ruff to template's `pyproject.toml` under dev extras.
- Added `conf.py` to template for configuring library.

### Changed

Expand Down
2 changes: 0 additions & 2 deletions examples/calver_inc/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ def should_skip(python: str, django: str) -> bool:
# Django main requires Python 3.10+
return True



if django == DJ50 and version(python) < version(PY310):
# Django 5.0 requires Python 3.10+
return True
Expand Down
2 changes: 0 additions & 2 deletions examples/calver_month/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ def should_skip(python: str, django: str) -> bool:
# Django main requires Python 3.10+
return True



if django == DJ50 and version(python) < version(PY310):
# Django 5.0 requires Python 3.10+
return True
Expand Down
2 changes: 0 additions & 2 deletions examples/default/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ def should_skip(python: str, django: str) -> bool:
# Django main requires Python 3.10+
return True



if django == DJ50 and version(python) < version(PY310):
# Django 5.0 requires Python 3.10+
return True
Expand Down
12 changes: 12 additions & 0 deletions src/django_twc_package/src/{{ module_name }}/_typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from __future__ import annotations

import sys

if sys.version_info >= (3, 12):
from typing import override as typing_override
else: # pragma: no cover
from typing_extensions import (
override as typing_override, # pyright: ignore[reportUnreachable]
)

override = typing_override
20 changes: 20 additions & 0 deletions src/django_twc_package/src/{{ module_name }}/conf.py.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from __future__ import annotations

from dataclasses import dataclass

from django.conf import settings

from ._typing import override

{{ module_name|upper }}_SETTINGS_NAME = "{{ module_name|upper }}"


@dataclass(frozen=True)
class AppSettings:
@override
def __getattribute__(self, __name: str) -> object:
user_settings = getattr(settings, {{ module_name|upper }}_SETTINGS_NAME, {})
return user_settings.get(__name, super().__getattribute__(__name)) # pyright: ignore[reportAny]


app_settings = AppSettings()