diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3d68edd..5fcc1b9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v3 @@ -42,7 +42,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.10' - name: Install black run: | diff --git a/django_group_role/management/commands/populate_roles.py b/django_group_role/management/commands/populate_roles.py index f8e71dd..331af3a 100644 --- a/django_group_role/management/commands/populate_roles.py +++ b/django_group_role/management/commands/populate_roles.py @@ -1,5 +1,6 @@ from django.core.management.base import BaseCommand -from ...roles import registry, load_roles, BadRoleException +from ...exceptions import BadRoleException +from ...roles import registry, load_roles def _fuzzy_search(rolenames): diff --git a/django_group_role/roles.py b/django_group_role/roles.py index 0d04073..16be0d0 100644 --- a/django_group_role/roles.py +++ b/django_group_role/roles.py @@ -1,12 +1,10 @@ import inspect -from contextlib import nullcontext, suppress from functools import partialmethod, reduce from importlib import import_module from django.core.exceptions import ImproperlyConfigured from django.utils.functional import cached_property -from .exceptions import BadRoleException from .signals import post_role_setup, pre_role_setup from .utils import get_permission, map_permissions @@ -73,13 +71,11 @@ def group(self): return group @classmethod - def iter_perms(cls, catch=False): - context = suppress(BadRoleException) if catch else nullcontext() + def iter_perms(cls): for app_label, app_perms in cls._permissions.items(): for modelname, perms in app_perms.items(): for perm in sorted(perms): - with context: - yield get_permission(perm, app_label, modelname) + yield get_permission(perm, app_label, modelname) def setup_permissions(self, clear=False): """Assignes declared permissions to this role group. diff --git a/django_group_role/test.py b/django_group_role/test.py index 07d2182..008d644 100644 --- a/django_group_role/test.py +++ b/django_group_role/test.py @@ -1,5 +1,6 @@ from django.test import override_settings -from .roles import load_roles, registry, BadRoleException +from .exceptions import BadRoleException +from .roles import load_roles, registry class RoleEnabledTestMixin: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1f90de2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,102 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +version = "0.7.2" +authors = [ + {"name"= "Davide Setti"}, +] +description = "Django Group-based roles" +name = "django-group-role" +requires-python = ">=3.10" +dependencies = [ + "django>=3.2,<5.1", +] +classifiers = [ + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.0", + "Framework :: Django :: 4.1", + "Framework :: Django :: 4.2", + "Framework :: Django :: 5.0", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Intended Audience :: Developers", +] +dynamic = ["readme"] + + +[project.optional-dependencies] +tests = [ + "coverage[toml]", + "pytest", + "pytest-django", + "pytest-cov", + "django-guardian~=2.4.0", +] + +[project.urls] +"Homepage" = "https://github.com/certego/django-group-role" +"Bug Tracker" = "https://github.com/certego/django-group-role/issues" + + +[tool.setuptools] +packages = ["django_group_role"] + +[tool.setuptools.dynamic] +readme = {file = ["README.md"]} + +[tool.coverage.run] +omit = [ + "*/migrations/*", + # do not check for templates + "*/templates/*", + # skip statics + "*/static/*", + "*/apps.py", +] + +branch = true + +source = [ + "django_group_role", +] + +[tool.pytest.ini_options] +DJANGO_SETTINGS_MODULE = "tests.example_project.settings" +django_find_project = false +pythonpath = "." + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = + py{310}-django32 + py{310,311,312}-django{40,41,42,50,master} + +[gh] +python = + 3.12 = py312 + 3.11 = py311 + 3.10 = py310 + +[testenv] +package = editable +extras = tests +whitelist_externals = py.test +commands = py.test +deps= + django32: Django>=3.2,<3.3 + django32: Django>=3.2,<3.3 + django40: Django>=4.0,<4.1 + django41: Django>=4.1,<4.2 + django42: Django>=4.2,<4.3 + django50: Django>=5.0a,<5.1 + djangomaster: https://github.com/django/django/archive/main.tar.gz +""" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index e13d39f..0000000 --- a/setup.cfg +++ /dev/null @@ -1,97 +0,0 @@ -[metadata] -name = django-group-role -version = 0.7.1 -author = Davide Setti -description = Django Group-based roles -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/certego/django-group-role -project_urls = - Bug Tracker = https://github.com/certego/django-group-role/issues -classifiers = - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Framework :: Django - Framework :: Django :: 3.2 - Framework :: Django :: 4.0 - Framework :: Django :: 4.1 - Framework :: Django :: 4.2 - Framework :: Django :: 5.0 - License :: OSI Approved :: Apache Software License - Operating System :: OS Independent - Intended Audience :: Developers - -[options] -packages = find: -python_requires = >=3.7 -install_requires = - Django>=3.2 - -tests_require = - pytest - pytest-django - pytest-cov - django-guardian~=2.4.0 - -[options.packages.find] -exclude = tests - -[aliases] -test=pytest - -[coverage:run] -omit = - */migrations/* - # do not check for templates - */templates/* - # skip statics - */static/* - */apps.py - -branch = true - -source = - django_group_role - -[tool:pytest] -DJANGO_SETTINGS_MODULE = tests.example_project.settings - -[tox:tox] -envlist = - py{37,38,39,310}-django32 - py{38,39,310,311,312}-django{40,41,42} - py{310,311,312}-django{50,master} - -[gh] -python = - 3.12 = py312 - 3.11 = py311 - 3.10 = py310 - 3.9 = py39 - 3.8 = py38 - 3.7 = py37 - -[testenv] -change_dir = tests -package = editable-legacy -extras = tests -whitelist_externals = py.test -commands = py.test -deps= - pytest - pytest-cov - pytest-django - django-guardian~=2.4.0 - django32: Django>=3.2,<3.3 - django32: Django>=3.2,<3.3 - django40: Django>=4.0,<4.1 - django41: Django>=4.1,<4.2 - django42: Django>=4.2,<4.3 - django50: Django>=5.0a,<5.1 - djangomaster: https://github.com/django/django/archive/main.tar.gz diff --git a/setup.py b/setup.py deleted file mode 100644 index c823345..0000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python -from setuptools import setup - -setup()