Skip to content

Commit 1e038fe

Browse files
committed
remove feature to specify required data in Meta
1 parent 658d1b7 commit 1e038fe

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

tests/test_page_inputs.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@ def test_html_response():
1616
assert response.headers["User-Agent"] == "test agent"
1717

1818

19-
def test_meta_required_data():
20-
Meta() # By default, no fields are required.
21-
22-
class RequiredMeta(Meta):
23-
required_data = {"some_data"}
24-
25-
with pytest.raises(ValueError):
26-
RequiredMeta()
27-
28-
meta = RequiredMeta(some_data=123)
29-
assert meta["some_data"] == 123
30-
31-
3219
def test_meta_restriction():
3320
# Any value that conforms with `Meta.restrictions` raises an error
3421
with pytest.raises(ValueError) as err:

web_poet/page_inputs.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,11 @@ class Meta(dict):
4141
functionalities to ensure consistent and compatible Page Objects across
4242
different use cases:
4343
44-
* A class variable named ``required_data`` to ensure consistent
45-
arguments. If it's instantiated with missing ``keys`` from
46-
``required_data``, then a ``ValueError`` is raised.
47-
4844
* Ensures that some params with data types that are difficult to
4945
provide or pass like ``lambdas`` are checked. Otherwise, a ``ValueError``
5046
is raised.
5147
"""
5248

53-
# Contains the required "keys" when instantiating and setting attributes.
54-
required_data: Set = set()
55-
5649
# Any "value" that returns True for the functions here are not allowed.
5750
restrictions: Dict = {
5851
inspect.ismodule: "module",
@@ -68,11 +61,6 @@ class Meta(dict):
6861
}
6962

7063
def __init__(self, *args, **kwargs) -> None:
71-
missing_required_keys = self.required_data - kwargs.keys()
72-
if missing_required_keys:
73-
raise ValueError(
74-
f"These keys are required for instantiation: {missing_required_keys}"
75-
)
7664
for val in kwargs.values():
7765
self.is_restricted_value(val)
7866
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)