Skip to content

Commit

Permalink
Version 1.3.0 release (#528)
Browse files Browse the repository at this point in the history
* Version 1.3.0 release

* Fix CI

* Fix CI
  • Loading branch information
sobolevn committed Mar 9, 2024
1 parent 520946c commit 68f877c
Show file tree
Hide file tree
Showing 15 changed files with 681 additions and 736 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Expand Up @@ -13,14 +13,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.10', '3.11', '3.12']
django-version:
- 'Django~=3.2.0'
- 'Django~=4.1.0'
- 'Django~=4.2.0'
- 'Django~=5.0.0'
include:
- python-version: '3.11'
django-version: 'Django~=4.2.0'
- python-version: '3.9'
django-version: 'Django~=4.1.0'
- python-version: '3.12'
django-version: 'Django~=4.1.0'

steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,18 @@
We follow Semantic Version.


## 1.3.0

### Features

- Drops `python3.8` support
- Adds `python3.11` and `python3.12` support
- Adds `django5.0` support
- Uses `OSError` instead of `IOError` alias
- Converts `include(*args, **kwargs)` to `include(*args, scope=...)`,
because other kwargs were not supported anyway


## 1.2.0

### Features
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -27,9 +27,9 @@ Also, check this [example project](https://github.com/wemake-services/wemake-dja

While this package will most likely work with the most versions of `django`, we [officially support](https://github.com/sobolevn/django-split-settings/blob/master/.github/workflows/test.yml):

- 3.2
- 4.1
- 4.2
- 5.0
- 5.1

This package has no dependencies itself.

Expand Down
2 changes: 0 additions & 2 deletions docs/conf.py
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
Expand Down
1,292 changes: 614 additions & 678 deletions poetry.lock

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-split-settings"
version = "1.2.0"
version = "1.3.0"
description = "Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files."
authors = [
"sobolevn <mail@sobolevn.me>",
Expand Down Expand Up @@ -32,6 +32,7 @@ classifiers = [
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
Expand All @@ -44,20 +45,23 @@ classifiers = [
"Funding" = "https://github.com/sponsors/wemake-services"

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.9"

[tool.poetry.group.test.dependencies]
django = "^4.2"
[tool.poetry.group.dev.dependencies]
django = [
{ version = "^4.2", python = "<3.10" },
{ version = "^5.0", python = ">=3.10" },
]

mypy = "^1.4"
wemake-python-styleguide = "^0.17"
mypy = "^1.9"
wemake-python-styleguide = "^0.18"
flake8-pytest-style = "^1.5"
nitpick = ">=0.33,<0.36"
nitpick = "^0.35"

doc8 = "^1.1"

pytest = ">=7.3,<9.0"
pytest-cov = "^4.0"
pytest = "^8.0"
pytest-cov = "^4.1"
pytest-randomly = "^3.12"

[tool.poetry.group.docs]
Expand All @@ -71,7 +75,7 @@ tomli = "^2.0"


[build-system]
requires = ["poetry-core>=1.6.0"]
requires = ["poetry-core>=1.9.0"]
build-backend = "poetry.masonry.api"


Expand Down
38 changes: 17 additions & 21 deletions setup.cfg
Expand Up @@ -6,9 +6,8 @@
# Base flake8 configuration:
# https://flake8.pycqa.org/en/latest/user/configuration.html
format = wemake
show-source = True
statistics = False
doctests = True
show-source = true
doctests = true

# darglint configuration:
# https://github.com/terrencepreilly/darglint
Expand Down Expand Up @@ -62,24 +61,21 @@ addopts =

[mypy]
# The mypy configurations: http://bit.ly/2zEl9WI
allow_redefinition = False
check_untyped_defs = True
disallow_untyped_decorators = True
disallow_any_explicit = True
disallow_any_generics = True
disallow_untyped_calls = True
ignore_errors = False
ignore_missing_imports = True
implicit_reexport = False
strict_optional = True
strict_equality = True
local_partial_types = True
no_implicit_optional = True
warn_unused_ignores = True
warn_redundant_casts = True
warn_unused_configs = True
warn_unreachable = True
warn_no_return = True
enable_error_code =
truthy-bool,
truthy-iterable,
redundant-expr,
unused-awaitable,
ignore-without-code,
possibly-undefined,
redundant-self,

ignore_missing_imports = true
strict = true
warn_unreachable = true

[mypy-tests.*]
disable_error_code = no-untyped-def


[doc8]
Expand Down
21 changes: 14 additions & 7 deletions split_settings/tools.py
Expand Up @@ -5,6 +5,8 @@
settings files.
"""

from __future__ import annotations

import glob
import inspect
import os
Expand Down Expand Up @@ -39,11 +41,14 @@ class _Optional(str): # noqa: WPS600
"""
Wrap a file path with this class to mark it as optional.
Optional paths don't raise an :class:`IOError` if file is not found.
Optional paths don't raise an :class:`OSError` if file is not found.
"""


def include(*args: str, **kwargs) -> None: # noqa: WPS210, WPS231, C901
def include( # noqa: WPS210, WPS231, C901
*args: str,
scope: dict[str, typing.Any] | None = None,
) -> None:
"""
Used for including Django project settings from multiple files.
Expand All @@ -52,7 +57,7 @@ def include(*args: str, **kwargs) -> None: # noqa: WPS210, WPS231, C901
**kwargs: Settings context: ``scope=globals()`` or ``None``.
Raises:
IOError: if a required settings file is not found.
OSError: if a required settings file is not found.
Usage example:
Expand All @@ -71,10 +76,10 @@ def include(*args: str, **kwargs) -> None: # noqa: WPS210, WPS231, C901
"""
# we are getting globals() from previous frame
# globals - it is caller's globals()
scope = kwargs.pop('scope', inspect.stack()[1][0].f_globals)
scope = scope or inspect.stack()[1][0].f_globals

scope.setdefault('__included_files__', [])
included_files = scope.get('__included_files__')
included_files = scope.get('__included_files__', [])

including_file = scope.get(
_INCLUDED_FILE,
Expand All @@ -90,7 +95,7 @@ def include(*args: str, **kwargs) -> None: # noqa: WPS210, WPS231, C901
# (unless file is optional)
files_to_include = glob.glob(pattern)
if not files_to_include and not isinstance(conf_file, _Optional):
raise IOError('No such file: {0}'.format(pattern))
raise OSError('No such file: {0}'.format(pattern))

for included_file in files_to_include:
included_file = os.path.abspath(included_file) # noqa: WPS440
Expand All @@ -114,7 +119,9 @@ def include(*args: str, **kwargs) -> None: # noqa: WPS210, WPS231, C901
)

spec = spec_from_file_location(module_name, included_file)
module = module_from_spec(spec) # type: ignore
# This is only needed for mypy:
assert spec is not None # noqa: S101
module = module_from_spec(spec)
sys.modules[module_name] = module
if saved_included_file:
scope[_INCLUDED_FILE] = saved_included_file
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
1 change: 0 additions & 1 deletion tests/settings/__init__.py
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
1 change: 0 additions & 1 deletion tests/settings/merged/components/__init__.py
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
1 change: 0 additions & 1 deletion tests/settings/merged/components/base.py
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Django settings for example project.

DEBUG = True
Expand Down
4 changes: 0 additions & 4 deletions tests/settings/merged/components/locale.py
Expand Up @@ -12,9 +12,5 @@
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
1 change: 0 additions & 1 deletion tests/settings/stacked/db/__init__.py
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
4 changes: 2 additions & 2 deletions tests/test_tools.py
Expand Up @@ -8,8 +8,8 @@


def test_missing_file_error(scope):
"""This test covers the IOError, when file does not exist."""
with pytest.raises(IOError, match='does-not-exist.py'):
"""This test covers the OSError, when file does not exist."""
with pytest.raises(OSError, match='does-not-exist.py'):
include('does-not-exist.py', scope=scope)


Expand Down

0 comments on commit 68f877c

Please sign in to comment.