Skip to content

Commit

Permalink
Do not consider type(None) injectable (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallaecio authored Jan 29, 2025
1 parent ece2bf9 commit c813a69
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
1 change: 1 addition & 0 deletions tests/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def to_item(self) -> dict: # type: ignore
}

assert is_injectable(None) is False
assert is_injectable(type(None)) is False
assert is_injectable(MyClass) is False
assert is_injectable(MyClass()) is False
assert is_injectable(MyItemPage) is True
Expand Down
4 changes: 0 additions & 4 deletions web_poet/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class Injectable(abc.ABC, FieldsMixin):
pass


# NoneType is considered as injectable. Required for Optionals to work.
Injectable.register(type(None))


def is_injectable(cls: Any) -> bool:
"""Return True if ``cls`` is a class which inherits
from :class:`~.Injectable`."""
Expand Down

0 comments on commit c813a69

Please sign in to comment.