Skip to content
Open
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__/
pip-wheel-metadata

# Virtualenv
.venv/
/env/
/src/

Expand All @@ -21,3 +22,7 @@ htmlcov

# Sphinx documentation
/doc/build/
/doc/_build/

# Type checkers
.mypy_cache/
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
rev: "7.3.0"
hooks:
- id: flake8
additional_dependencies: [flake8-pyproject]
additional_dependencies: [flake8-pyproject, flake8-type-checking]
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
Expand Down
14 changes: 8 additions & 6 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
CHANGES
*******

0.15 (unreleased)
=================
1.0.0 (unreleased)
==================

- Add type hints

- Add partial attribute to directive methods for better typing support

- Fix Flake8 errors.

- Apply Black code formatter.
- Fix linting errors.

- Add support for Python 3.10, 3.11, 3.12, 3.13 and 3.14

- Drop support for Python 3.9 and below

- Use GitHub Actions instead of Travis for CI.
(Travis no longer gives free credits to open source projects.)
(Travis no longer gives free credits to open source projects.)

- Cleanup old Python 2 code with pyupgrade_.

- Add tests for 100% coverage.

- Update docs.

.. _pyupgrade: https://github.com/asottile/pyupgrade


Expand Down
2 changes: 1 addition & 1 deletion CREDITS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CREDITS

* Denis Krienbühl (testing and feedback)

* Henri Hulski (build environment)
* Henri Hulski (build environment and maintainer)

* Jan Stürtz

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Dectate is a powerful configuration engine for Python frameworks.

`Read the docs`_

.. _`Read the docs`: http://dectate.readthedocs.org
.. _`Read the docs`: https://dectate.readthedocs.io

It is used by Morepath_.

.. _Morepath: http://morepath.readthedocs.org
.. _Morepath: https://morepath.readthedocs.io
10 changes: 5 additions & 5 deletions dectate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from .app import App, directive
from .sentinel import Sentinel, NOT_FOUND
from .config import commit, Action, Composite, CodeInfo
from .config import Action, CodeInfo, Composite, commit
from .error import (
ConfigError,
ConflictError,
DirectiveError,
TopologicalSortError,
DirectiveReportError,
ConflictError,
QueryError,
TopologicalSortError,
)
from .query import Query
from .tool import query_tool, convert_dotted_name, convert_bool, query_app
from .sentinel import NOT_FOUND, Sentinel
from .tool import convert_bool, convert_dotted_name, query_app, query_tool
from .toposort import topological_sort

__all__ = (
Expand Down
17 changes: 8 additions & 9 deletions dectate/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
TypeVar,
cast,
)

from .config import Configurable, Directive, commit, create_code_info

if TYPE_CHECKING:
from collections.abc import Callable, Collection, Iterator
from typing_extensions import Self

from .config import Action, Composite, DirectiveAbbreviation
from .types import DirectiveCallable

_T = TypeVar("_T")
_ActionT = TypeVar("_ActionT", bound="Action | Composite")
_AppT = TypeVar("_AppT", bound="App")
_P = ParamSpec("_P")
Expand Down Expand Up @@ -173,7 +174,7 @@ class DirectiveMethod(Generic[_AppT, _P]):
__name__: str
__qualname__: str

def __init__(self, func: DirectiveCallable[Concatenate[Any, _P]]):
def __init__(self, func: DirectiveCallable[Concatenate[Any, _P]]) -> None:
self.__func__ = func
update_wrapper(self, func) # type: ignore[arg-type]

Expand All @@ -197,8 +198,8 @@ def directive(
:class:`dectate.Composite` subclass and can attach the result as a
class method to an :class:`dectate.App` subclass::

class FooAction(dectate.Action):
...
class FooAction(dectate.Action): ...


class MyApp(dectate.App):
my_directive = dectate.directive(MyAction)
Expand All @@ -208,16 +209,14 @@ class MyApp(dectate.App):

class MyApp(dectate.App):
@directive
class my_directive(dectate.Action):
...
class my_directive(dectate.Action): ...

:param action_factory: an action class to use as the directive.
:return: a class method that represents the directive.
"""
if not isinstance(action_factory, type):
raise TypeError(
"action_factory needs to be `dectate.Action` or `dectate.Composite` subclass."
)
msg = "action_factory needs to be `dectate.Action` or `dectate.Composite` subclass."
raise TypeError(msg)

def method(cls: Any, *args: _P.args, **kw: _P.kwargs) -> Directive:
frame = sys._getframe(2)
Expand Down
Loading
Loading