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

Update nodedriver decorator #272

Merged
Merged
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
6 changes: 4 additions & 2 deletions src/feditest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from enum import Enum
from inspect import getmembers, getmodule, isfunction
from types import FunctionType
from typing import Any, Type, TypeVar, cast
from typing import Any, Type, TypeVar, cast

from hamcrest.core.matcher import Matcher
from hamcrest.core.string_description import StringDescription
Expand Down Expand Up @@ -174,8 +174,9 @@ def load_node_drivers_from(dirs: list[str]) -> None:
# Holds all node drivers
all_node_drivers : dict[str,Type[Any]]= {}

TDriver = TypeVar('NodeDriver')

def nodedriver(to_register: Type[Any]):
def nodedriver(to_register: Type[TDriver]) -> Type[TDriver]:
"""
Used as decorator of NodeDriver classes, like this:

Expand All @@ -199,6 +200,7 @@ class XYZDriver : ...
fatal('Cannot re-register NodeDriver', full_name )
all_node_drivers[full_name] = to_register

return to_register

class SpecLevel(Enum):
MUST = 1
Expand Down